private (TS277, long) Get277(Edi.Templates.Hipaa5010.TS837P ts837Data = null) { TS277 input277Data = new TS277(); input277Data = FetchData277(ts837Data); long cntlNum = _cAERepository.GetNextSequence("trnId"); var transaction = HipaaTransactionBuilders.Build277ResponseTransmission(cntlNum.ToString(), input277Data); //using (var stream = new MemoryStream()) //{ // using (var writer = new X12Writer(stream)) // { // writer.Write(SegmentBuilders.BuildIsa("1")); // writer.Write(SegmentBuilders.BuildGs("1")); // writer.Write(transaction); // } // var ediString = stream.LoadToString(); // return ediString; //} return(transaction, cntlNum); }
private TS277 FetchData277(Edi.Templates.Hipaa5010.TS837P data = null) { TS277 ts277Data = new TS277(); ts277Data.Loop2000A = new List <Loop_2000A_277>(); var loop2000A = new Loop_2000A_277(); loop2000A.Loop2100A = new Loop_2100A_277(); loop2000A.Loop2100A.NM1_PayerName = new NM1_CorrectedPriorityPayerName(); // End 2000A Loop ts277Data.Loop2000A.Add(loop2000A); ts277Data.Loop2000A[0].Loop2100A.NM1_PayerName.ResponseContactLastorOrganizationName_03 = data.Loop2000A[0].Loop2000B[0].AllNM1.Loop2010BB.NM1_PayerName.ResponseContactLastorOrganizationName_03; ts277Data.Loop2000A[0].Loop2100A.NM1_PayerName.ResponseContactIdentifier_09 = data.Loop2000A[0].Loop2000B[0].AllNM1.Loop2010BB.NM1_PayerName.ResponseContactIdentifier_09; loop2000A.Loop2000B = new List <Loop_2000B_277>(); var loop2000B = new Loop_2000B_277(); loop2000B.Loop2100B = new Loop_2100B_277(); loop2000B.Loop2100B.NM1_InformationReceiverName = new NM1_InformationReceiverName_2(); // End 2000B Loop loop2000A.Loop2000B.Add(loop2000B); ts277Data.Loop2000A[0].Loop2000B[0].Loop2100B.NM1_InformationReceiverName.ResponseContactLastorOrganizationName_03 = data.Loop2000A[0].AllNM1.Loop2010AA.NM1_BillingProviderName.ResponseContactLastorOrganizationName_03; ts277Data.Loop2000A[0].Loop2000B[0].Loop2100B.NM1_InformationReceiverName.ResponseContactIdentifier_09 = data.Loop2000A[0].AllNM1.Loop2010AA.NM1_BillingProviderName.ResponseContactIdentifier_09; loop2000B.Loop2000C = new List <Loop_2000C_277>(); // Begin 2000C Loop 1 var loop2000C1 = new Loop_2000C_277(); loop2000C1.Loop2100C = new List <Loop_2100C_277>(); // Begin 2100C Loop var loop2100C = new Loop_2100C_277(); loop2000C1.Loop2100C.Add(loop2100C); // Repeating 2000D Loops loop2000C1.Loop2000D = new List <Loop_2000D_277>(); // Begin 2000D Loop 1 var loop2000D1 = new Loop_2000D_277(); // Begin 2100D Loop loop2000D1.Loop2100D = new Loop_2100D_277(); loop2000D1.Loop2100D.NM1_SubscriberName = new NM1_InsuredName(); loop2000C1.Loop2000D.Add(loop2000D1); loop2000B.Loop2000C.Add(loop2000C1); ts277Data.Loop2000A[0].Loop2000B[0].Loop2000C[0].Loop2000D[0].Loop2100D.NM1_SubscriberName.ResponseContactLastorOrganizationName_03 = data.Loop2000A[0].Loop2000B[0].AllNM1.Loop2010BA.NM1_SubscriberName.ResponseContactLastorOrganizationName_03;//"SMITH"; ts277Data.Loop2000A[0].Loop2000B[0].Loop2000C[0].Loop2000D[0].Loop2100D.NM1_SubscriberName.ResponseContactFirstName_04 = data.Loop2000A[0].Loop2000B[0].AllNM1.Loop2010BA.NM1_SubscriberName.ResponseContactFirstName_04; ts277Data.Loop2000A[0].Loop2000B[0].Loop2000C[0].Loop2000D[0].Loop2100D.NM1_SubscriberName.IdentificationCodeQualifier_08 = data.Loop2000A[0].Loop2000B[0].AllNM1.Loop2010BA.NM1_SubscriberName.IdentificationCodeQualifier_08; ts277Data.Loop2000A[0].Loop2000B[0].Loop2000C[0].Loop2000D[0].Loop2100D.NM1_SubscriberName.ResponseContactIdentifier_09 = data.Loop2000A[0].Loop2000B[0].AllNM1.Loop2010BA.NM1_SubscriberName.ResponseContactIdentifier_09; loop2000D1.Loop2200D = new List <Loop_2200D_277>(); // Begin 2200D Loop var loop2200D = new Loop_2200D_277(); loop2000D1.Loop2200D.Add(loop2200D); loop2200D.STC_ClaimLevelStatusInformation = new List <STC_BillingProviderStatusInformation>(); //get the list of LOINC codes and add a request for each foreach (string reqCode in GetRequestCodes(data.Loop2000A[0].Loop2000B[0].Loop2300[0].Loop2400[0].SV1_ProfessionalService.CompositeMedicalProcedureIdentifier_01.ProcedureCode_02).Result.Distinct()) { var stc1 = new STC_BillingProviderStatusInformation(); stc1.HealthCareClaimStatus_01 = new C043_HealthCareClaimStatus(); loop2200D.STC_ClaimLevelStatusInformation.Add(stc1); //ex STC*R4:18657-7::LOI*2*3*4*5*6*7*8*9*R4:18803-7::LOI~ stc1.HealthCareClaimStatus_01.HealthCareClaimStatusCategoryCode_01 = "R4"; stc1.HealthCareClaimStatus_01.StatusCode_02 = reqCode;// GetCPT2Loinc(data.Loop2000A[0].Loop2000B[0].Loop2300[0].Loop2400[0].SV1_ProfessionalService.CompositeMedicalProcedureIdentifier_01.ProcedureCode_02);//"19016-5";// 18657-7"; stc1.HealthCareClaimStatus_01.CodeListQualifierCode_04 = "LOI"; stc1.Date_02 = String.Format("{0:yyyyMMdd}", System.DateTime.UtcNow.AddDays(30)); stc1.HealthCareClaimStatus_10 = new C043_HealthCareClaimStatus(); stc1.HealthCareClaimStatus_10.HealthCareClaimStatusCategoryCode_01 = "R4"; stc1.HealthCareClaimStatus_10.StatusCode_02 = "18594-2";//"18803-7"; stc1.HealthCareClaimStatus_10.CodeListQualifierCode_04 = "LOI"; } //end of the list request // stc1.HealthCareClaimStatus_11 = ""; loop2200D.AllREF = new All_REF_277(); loop2200D.AllREF.REF_PatientControlNumber = new REF_PatientControlNumber(); loop2200D.AllREF.REF_PatientControlNumber.MemberGrouporPolicyNumber_02 = data.Loop2000A[0].Loop2000B[0].Loop2300[0].CLM_ClaimInformation.PatientControlNumber_01; return(ts277Data); }