0

I have an elastic post API. To fetch the data from the post API I am using the below JSON code in the body section in postman.

{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "platform": {
              "query": "COSMOS"
            }
          }
        }
      ],
      "filter": [
        {
          "range": {
            "cu_ticketLastUpdated_date": {
              "gte": "2022-05-30 00:00:00",
              "lt": "2022-05-31 23:59:59"
            }
          }
        }
      ]
    }
  }
}

Below is the JSON data which is getting post execution of above filters in the body section in postman

{
    "took": 513,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 42,
            "relation": "eq"
        },
        "max_score": 3.2640164,
        "hits": [
            {
                "_index": "piqreporting",
                "_type": "ticketData",
                "_id": "9845628",
                "_score": 3.2640164,
                "_source": {
                    "claimNumber": "1234556",
                    "adjustmentNumber": "XXXXXXXXX",
                    "claimICN": "XXXXXXXXX",
                    "claimStatus": "A",
                    "claimType": "I",
                    "claimFirstDateService": "2020-06-02",
                    "claimLastDateService": "2020-06-03",
                    "isBehaviourHealth": "false",
                    "claimPatientAccountNumber": "52088867500",
                    "claimBillingAmount": "6287.91",
                    "claimPaidAmount": "2579.66",
                    "claimCAE": "COSMOS",
                    "subscriberId": "943634985",
                    "memberId": "943634985",
                    "subscriberFirstName": "CLAYTON",
                    "subscriberLastName": "CASH",
                    "subscriberDateOfBirth": "1969-01-06",
                    "subscriberAddress": "163 BLAKE ST APT 1 ",
                    "patientFirstName": "CLAYTON",
                    "patientLastName": "CASH",
                    "patientMiddleName": "A",
                    "patientDateOfBirth": "1969-01-06",
                    "govProgramCode": "2",
                    "coverageStartDate": "2020-04-01",
                    "coverageEndDate": "2020-12-31",
                    "relationshipCode": "EE",
                    "divisionCode": "NYC",
                    "sourceId": "NYC6610094363498500",
                    "billingMpin": "000568859",
                    "billingProviderName": "Yale New Haven Hospital",
                    "renderingMpin": "003928974",
                    "ticketNumber": "9845628",
                    "tpsmCode": "S",
                    "ticketTpsmIndicator": "134",
                    "ticketTpsmEffectiveDate": "2017-06-01",
                    "ticketSubmissionDate": "2022-05-30",
                    "ticketSubmitterName": "Durga Singidi",
                    "ticketType": "Recon",
                    "ticketQueue": "Cosmos Inst SAS MnR",
                    "providerTin": "060646652",
                    "policyNumber": "66100",
                    "sharedAmount": "00",
                    "ticketStatus": "Under Review",
                    "ticketSubmitterEmail": "XXXXXXXXX",
                    "ticketSubmitterPhone": "1234567890",
                    "amountOwned": "878.00",
                    "amountOwnedFlag": "N",
                    "ticketLastUpdated": "2022-05-30",
                    "ticketLastUpdatedBy": "System",
                    "claimSubmissionTransactionId": "N/A",
                    "sourceApplication": "SDE",
                    "serviceProviderLastName": "Yale New Haven Hospital",
                    "productId": "00526",
                    "depedentSequenceNumber": "00",
                    "stateOfIssue": "CT",
                    "subscriberAddressLine1": "163 BLAKE ST APT 1",
                    "subscriberCity": "NEW HAVEN",
                    "subscriberState": "CT",
                    "subscriberZip5": "06515",
                    "billingType": "131",
                    "claimIndicator": "I",
                    "claimRecievedDate": "2020-06-08",
                    "ticketLastUpdatedName": "System",
                    "ticketTpsmCancelDate": "9999-12-31",
                    "planBenefitTypeCode": "MD",
                    "claimNetworkStatus": "I",
                    "offshoreRestricted": "N",
                    "isEmployeeRestricted": "N",
                    "providerComments": "Integration testing with PIQ for COSMOS",
                    "platform": "COSMOS",
                    "payerId": "87726",
                    "payerName": "UnitedHealthcare",
                    "kafkaWorkflow": "COMPLETED",
                    "resubmissionCount": "0",
                    "assignedTopic": "STOP",
                    "cu_ticketSubmittedDate_date": "2022-05-30 09:58:33",
                    "cu_ticketLastUpdated_date": "2022-05-30 09:59:34.057",
                    "cu_ticketNumber": "PIQ-9845628",
                    "cu_totalAttachments_int": 0,
                    "cu_resubmission_count_int": 0,
                    "cu_bizAge_int": 1,
                    "actualClaimNumber": "NYC094995559",
                    "coverageType": "M",
                    "remarkCodes": "0208",
                    "advocateCreatedOn": "2022-05-30",
                    "ticketAdjustment": [
                        {
                            "adjustmentNumber": "XXXXXXXXX",
                            "adjustmentSource": "COSMOS",
                            "createdOn": "2022-05-30"
                        }
                    ],
                    "ticketResubmissions": [
                        {
                            "openDate": "2022-05-30"
                        }
                    ],
                    "ticketComments": [
                        {
                            "comment": "Integration testing with PIQ for COSMOS",
                            "category": "External",
                            "createdBy": "Durga Singidi",
                            "createDate": "2022-05-30",
                            "reconRequestReason": "Reimbursement or Medical Policy Decision"
                        },
                        {
                            "comment": "Under Review",
                            "category": "Internal",
                            "createdBy": "System",
                            "ticketStatus": "Under Review",
                            "createDate": "2022-05-30",
                            "conclusion": "Under Review",
                            "reconRequestReason": "Reimbursement or Medical Policy Decision",
                            "createdById": "System"
                        }
                    ]
                }
            },
            {
                "_index": "piqreporting",
                "_type": "ticketData",
                "_id": "9845624",
                "_score": 0.0,
                "_source": {
                    "claimNumber": "XXXXXXXXX",
                    "adjustmentNumber": "XXXXXXXXX",
                    "claimICN": "XXXXXXXXX",
                    "claimStatus": "A",
                    "claimType": "P",
                    "claimFirstDateService": "2021-07-03",
                    "claimLastDateService": "2021-07-03",
                    "isBehaviourHealth": "false",
                    "claimPatientAccountNumber": "XXXXXXXXX",
                    "claimBillingAmount": "1330.00",
                    "claimPaidAmount": "63.97",
                    "claimCAE": "FACETS - CSP",
                    "subscriberId": "121586082",
                    "memberId": "121586082",
                    "subscriberFirstName": "STEPHEN",
                    "subscriberLastName": "BOLDIN",
                    "subscriberDateOfBirth": "1965-02-24",
                    "subscriberAddress": "2137 N. BELL AVENUE ",
                    "patientFirstName": "STEPHEN",
                    "patientLastName": "BOLDIN",
                    "patientMiddleName": "W",
                    "patientDateOfBirth": "1965-02-24",
                    "govProgramCode": "3",
                    "coverageStartDate": "2021-07-01",
                    "coverageEndDate": "9999-12-31",
                    "groupNumber": "AZMC",
                    "relationshipCode": "EE",
                    "sourceId": "AZMCARE 12158608201",
                    "billingMpin": "000121184",
                    "billingProviderName": "Tucson Medical Center",
                    "renderingMpin": "000121184",
                    "renderingProviderName": "NADER MAKKI",
                    "ticketNumber": "9845624",
                    "tpsmCode": "S",
                    "ticketTpsmIndicator": "424",
                    "ticketTpsmEffectiveDate": "2017-12-20",
                    "ticketSubmissionDate": "2022-05-30",
                    "ticketSubmitterName": "Durga Singidi",
                    "ticketType": "Recon",
                    "ticketQueue": "Facets  CSP",
                    "providerTin": "860137567",
                    "policyNumber": "AZMCARE",
                    "ticketStatus": "Under Review",
                    "ticketSubmitterEmail": "XXXXXXXXX",
                    "ticketSubmitterPhone": "1234567890",
                    "amountOwned": "676.00",
                    "amountOwnedFlag": "N",
                    "ticketLastUpdated": "2022-05-30",
                    "ticketLastUpdatedBy": "System",
                    "claimSubmissionTransactionId": "N/A",
                    "sourceApplication": "SDE",
                    "serviceProviderLastName": "Tucson Medical Center",
                    "productId": "AZMCARE",
                    "depedentSequenceNumber": "01",
                    "stateOfIssue": "AZ",
                    "subscriberAddressLine1": "2137 N. BELL AVENUE",
                    "subscriberCity": "TUCSON",
                    "subscriberState": "AZ",
                    "subscriberZip5": "857120000",
                    "claimIndicator": "I",
                    "claimRecievedDate": "2021-07-23",
                    "ticketLastUpdatedName": "System",
                    "ticketTpsmCancelDate": "9999-12-31",
                    "planBenefitTypeCode": "MD",
                    "claimNetworkStatus": "I",
                    "offshoreRestricted": "N",
                    "isEmployeeRestricted": "N",
                    "providerComments": "Integration testing with PIQ",
                    "platform": "FACETS - CSP",
                    "payerId": "87726",
                    "payerName": "UnitedHealthcare",
                    "kafkaWorkflow": "COMPLETED",
                    "providerRequestReason": "Patient Eligibility",
                    "resubmissionCount": "0",
                    "assignedTopic": "STOP",
                    "cu_ticketSubmittedDate_date": "2022-05-30 09:41:05",
                    "cu_ticketLastUpdated_date": "2022-05-30 09:42:54.394",
                    "cu_ticketNumber": "PIQ-9845624",
                    "cu_totalAttachments_int": 0,
                    "cu_resubmission_count_int": 0,
                    "cu_bizAge_int": 1,
                    "actualClaimNumber": "21H991583800",
                    "coverageType": "M",
                    "facetsprovIdBilling": "0808709004",
                    "facetsprovIdRendering": "6817639003",
                    "remarkCodes": "PXN",
                    "advocateCreatedOn": "2022-05-30",
                    "ticketAdjustment": [
                        {
                            "adjustmentNumber": "SF20220530824490967",
                            "adjustmentSource": "FACETS - CSP",
                            "createdOn": "2022-05-30"
                        }
                    ],
                    "ticketResubmissions": [
                        {
                            "openDate": "2022-05-30"
                        }
                    ],
                    "ticketComments": [
                        {
                            "comment": "Integration testing with PIQ",
                            "category": "External",
                            "createdBy": "Durga Singidi",
                            "createDate": "2022-05-30",
                            "reconRequestReason": "Patient Eligibility"
                        },
                        {
                            "comment": "Under Review",
                            "category": "Internal",
                            "createdBy": "System",
                            "ticketStatus": "Under Review",
                            "createDate": "2022-05-30",
                            "conclusion": "Under Review",
                            "reconRequestReason": "Patient Eligibility",
                            "createdById": "System"
                        }
                    ]
                }
            },
            {
                "_index": "piqreporting",
                "_type": "ticketData",
                "_id": "9845631",
                "_score": 0.0,
                "_source": {
                    "claimNumber": "XXXXXXXXX",
                    "claimICN": "XXXXXXXXX",
                    "claimStatus": "01",
                    "claimType": "I",
                    "claimFirstDateService": "2021-11-14",
                    "claimLastDateService": "2021-11-14",
                    "isBehaviourHealth": "false",
                    "claimPatientAccountNumber": "53010242800",
                    "claimBillingAmount": "737.88",
                    "claimPaidAmount": "369.98",
                    "claimCAE": "CIRRUS",
                    "subscriberId": "720845839",
                    "memberId": "72084583900",
                    "subscriberFirstName": "RACHEL",
                    "subscriberLastName": "PERDO",
                    "subscriberDateOfBirth": "1987-10-18",
                    "subscriberAddress": "330 SHORT BEACH ROAD APARTMENT I 12",
                    "patientFirstName": "RACHEL",
                    "patientLastName": "PERDO",
                    "patientDateOfBirth": "1987-10-18",
                    "coverageStartDate": "2021-09-01",
                    "coverageEndDate": "9999-12-31",
                    "groupNumber": "1273808",
                    "relationshipCode": "EE",
                    "sourceId": "72084583900",
                    "billingMpin": "000568859",
                    "billingProviderName": "Yale New Haven Hospital",
                    "renderingMpin": "005231819",
                    "ticketNumber": "9845631",
                    "tpsmCode": "S",
                    "ticketTpsmIndicator": "134",
                    "ticketTpsmDescription": "STRATEGIC_NE_YALE LAWRENCE & MEMORIAL",
                    "ticketTpsmEffectiveDate": "2017-06-01",
                    "ticketSubmissionDate": "2022-05-30",
                    "ticketSubmitterName": "Shrutika Kadam",
                    "ticketType": "Recon",
                    "ticketQueue": "Cirrus Triage General",
                    "providerTin": "060646652",
                    "policyNumber": "1273808",
                    "ticketStatus": "New",
                    "ticketSubmitterEmail": "XXXXXXXXX",
                    "ticketSubmitterPhone": "9876543210",
                    "amountOwned": "990.00",
                    "amountOwnedFlag": "N",
                    "ticketLastUpdated": "2022-05-30",
                    "ticketLastUpdatedBy": "System",
                    "claimSubmissionTransactionId": "N/A",
                    "sourceApplication": "SDE",
                    "serviceProviderFirstName": "Pirjo",
                    "serviceProviderLastName": "Aalto Fischer",
                    "productId": "PM00000013",
                    "stateOfIssue": "CT",
                    "subscriberAddressLine1": "330 SHORT BEACH ROAD",
                    "subscriberAddressLine2": "APARTMENT I 12",
                    "subscriberCity": "EAST HAVEN",
                    "subscriberState": "CT",
                    "subscriberZip5": "06512",
                    "billingType": "131",
                    "claimIndicator": "I",
                    "claimRecievedDate": "2021-12-03",
                    "ticketLastUpdatedName": "System",
                    "ticketTpsmCancelDate": "9999-12-31",
                    "claimNetworkStatus": "I",
                    "offshoreRestricted": "N",
                    "isEmployeeRestricted": "N",
                    "providerComments": "test",
                    "platform": "CIRRUS",
                    "payerId": "06111",
                    "payerName": "Oxford Health Plans, Inc.",
                    "kafkaWorkflow": "COMPLETED",
                    "providerRequestReason": "Paper or Electronic Check",
                    "resubmissionCount": "0",
                    "assignedTopic": "STOP",
                    "cu_ticketSubmittedDate_date": "2022-05-30 10:00:49",
                    "cu_ticketLastUpdated_date": "2022-05-30 10:01:27.015",
                    "cu_ticketNumber": "PIQ-9845631",
                    "cu_totalAttachments_int": 0,
                    "cu_resubmission_count_int": 0,
                    "cu_bizAge_int": 1,
                    "bookOfBusinessTypeCd": "OX",
                    "actualClaimNumber": "DC29723201",
                    "coverageType": "M",
                    "remarkCodes": "PPO008,COVD01",
                    "smbInd": "F",
                    "advocateCreatedOn": "2022-05-30",
                    "ticketResubmissions": [
                        {
                            "openDate": "2022-05-30"
                        }
                    ],
                    "ticketComments": [
                        {
                            "comment": "test",
                            "category": "External",
                            "createdBy": "Shrutika Kadam",
                            "createDate": "2022-05-30",
                            "reconRequestReason": "Paper or Electronic Check"
                        }
                    ]
                }
            },
            {
                "_index": "piqreporting",
                "_type": "ticketData",
                "_id": "9845638",
                "_score": 0.0,
                "_source": {
                    "claimNumber": "XXXXXXXXX",
                    "adjustmentNumber": "XXXXXXXXX",
                    "claimICN": "XXXXXXXXX",
                    "claimStatus": "A",
                    "claimType": "I",
                    "claimFirstDateService": "2022-01-03",
                    "claimLastDateService": "2022-01-03",
                    "isBehaviourHealth": "false",
                    "claimPatientAccountNumber": "XXXXXXXXX",
                    "claimBillingAmount": "393.77",
                    "claimPaidAmount": "292.61",
                    "claimCAE": "FACETS - CSP",
                    "subscriberId": "122220435",
                    "memberId": "122220435",
                    "subscriberFirstName": "CHARLES",
                    "subscriberLastName": "TAYLOR",
                    "subscriberDateOfBirth": "1997-01-30",
                    "subscriberAddress": "15025 OAKS ROAD ",
                    "patientFirstName": "CHARLES",
                    "patientLastName": "TAYLOR",
                    "patientMiddleName": "G",
                    "patientDateOfBirth": "1997-01-30",
                    "govProgramCode": "0",
                    "coverageStartDate": "2022-01-01",
                    "coverageEndDate": "9999-12-31",
                    "groupNumber": "EXSG",
                    "relationshipCode": "EE",
                    "sourceId": "MDONEX  12222043501",
                    "billingMpin": "001131959",
                    "billingProviderName": "Murphy Medical Center",
                    "renderingMpin": "001131959",
                    "ticketNumber": "9845638",
                    "tpsmCode": "F",
                    "ticketTpsmIndicator": "99Z",
                    "ticketTpsmDescription": "DEFAULT VALUE",
                    "ticketSubmissionDate": "2022-05-30",
                    "ticketSubmitterName": "Lavanya Kadiala",
                    "ticketType": "Recon",
                    "ticketQueue": "Facets  CSP",
                    "providerTin": "520445374",
                    "policyNumber": "MDONEX",
                    "ticketStatus": "Under Review",
                    "ticketSubmitterEmail": "XXXXXXXXX",
                    "ticketSubmitterPhone": "8748468777",
                    "amountOwnedFlag": "Y",
                    "ticketLastUpdated": "2022-05-30",
                    "ticketLastUpdatedBy": "System",
                    "claimSubmissionTransactionId": "N/A",
                    "sourceApplication": "SDE",
                    "serviceProviderLastName": "Civista Medical Center",
                    "productId": "BVSCMD08",
                    "depedentSequenceNumber": "01",
                    "stateOfIssue": "MD",
                    "subscriberAddressLine1": "15025 OAKS ROAD",
                    "subscriberCity": "CHARLOTTE HALL",
                    "subscriberState": "MD",
                    "subscriberZip5": "20622",
                    "billingType": "131",
                    "claimIndicator": "O",
                    "claimRecievedDate": "2022-01-18",
                    "ticketLastUpdatedName": "System",
                    "planBenefitTypeCode": "MD",
                    "claimNetworkStatus": "O",
                    "offshoreRestricted": "N",
                    "isEmployeeRestricted": "N",
                    "providerComments": "PIQ Integration testing smb data",
                    "platform": "FACETS - CSP",
                    "payerId": "87726",
                    "payerName": "UnitedHealthcare",
                    "kafkaWorkflow": "COMPLETED",
                    "providerRequestReason": "Paper or Electronic Check",
                    "resubmissionCount": "0",
                    "assignedTopic": "STOP",
                    "cu_ticketSubmittedDate_date": "2022-05-30 10:34:28",
                    "cu_ticketLastUpdated_date": "2022-05-30 10:35:55.868",
                    "cu_ticketNumber": "PIQ-9845638",
                    "cu_totalAttachments_int": 0,
                    "cu_resubmission_count_int": 0,
                    "cu_bizAge_int": 1,
                    "actualClaimNumber": "22A647807600",
                    "coverageType": "M",
                    "facetsprovIdBilling": "0421644502",
                    "facetsprovIdRendering": "0421644001",
                    "remarkCodes": "i61",
                    "smbInd": "S",
                    "smbProvStCd": "MD",
                    "advocateCreatedOn": "2022-05-30",
                    "ticketAdjustment": [
                        {
                            "adjustmentNumber": "SF20220530824490968",
                            "adjustmentSource": "FACETS - CSP",
                            "createdOn": "2022-05-30"
                        }
                    ],
                    "ticketResubmissions": [
                        {
                            "openDate": "2022-05-30"
                        }
                    ],
                    "ticketComments": [
                        {
                            "comment": "PIQ Integration testing smb data",
                            "category": "External",
                            "createdBy": "Lavanya Kadiala",
                            "createDate": "2022-05-30",
                            "reconRequestReason": "Paper or Electronic Check"
                        },
                        {
                            "comment": "Under Review",
                            "category": "Internal",
                            "createdBy": "System",
                            "ticketStatus": "Under Review",
                            "createDate": "2022-05-30",
                            "conclusion": "Under Review",
                            "reconRequestReason": "Paper or Electronic Check",
                            "createdById": "System"
                        }
                    ]
                }
            }
        ]
    }
}

I need to get the data from the elasticsearch by adding the filters like cu_ticketLastUpdated_date and platform columns. To achieve this I am using the below c# code

public static string COSMOS(string getAPiurl, string ApiUserId, string ApiPassword)
{
    string url = getAPiurl;
    HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url);

    webrequest.Method = "POST";
    webrequest.ContentType = "application/JSON";
    webrequest.Accept = "application/JSON";

    String username = ApiUserId;
    String password = ApiPassword;
    String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));

    webrequest.Headers.Add("Authorization", "Basic " + encoded);

    using (var streamWriter = new StreamWriter(webrequest.GetRequestStream()))
    {
        string json = "{\"query\":{\"bool\":{\"should\":[{\"match\":{\"platform\":{\"query\":\"COSMOS\"}}}],\"filter\":[{\"range\":{\"cu_ticketLastUpdated_date\":{\"gte\":\"2022-05-01 00:00:00\",\"lt\":\"2022-05-31 23:59:59\"}}}]}}}";

        streamWriter.Write(json);
    }

    var httpResponse = (HttpWebResponse)webrequest.GetResponse();

    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
    {
        var rl = streamReader.ReadToEnd();
        httpResponse.Close();
    }
}

I am unable to get the response from the API. Can anyone help me with a solution.

Paulo
  • 8,690
  • 5
  • 20
  • 34
Learner
  • 25
  • 5
  • Could you share the error that you observe ? what is the result of the request ? – Paulo May 31 '22 at 20:03
  • I am not getting the data as per my request. I need to fetch the data only belongs to the platform: COSMOS. But instead of that I am getting entire data from that API which includes all the platform departments. – Learner Jun 01 '22 at 04:36
  • So from my understanding both the `c#` example and the dsl query in postman do not work ? They both return multiple kind of platforms such as `CIRRUS` / `COSMOS` / `Facet - CSP` ? – Paulo Jun 01 '22 at 06:33
  • Which indicate the error not to be with the `c#` example but the request you send ? – Paulo Jun 01 '22 at 06:34
  • You may want to add the mapping of your index. (maybe not all of it but just the fields relevant to the question). For example you response dump is nice ... but contains way to much information – Paulo Jun 01 '22 at 07:47

1 Answers1

0

Tldr;

Why don't you use the official c# library ?

Paulo
  • 8,690
  • 5
  • 20
  • 34