/// <summary> /// Transforms provided <see cref="J400Claim"/> object to a collection of <see cref="FormPage"/> /// </summary> /// <param name="j400">Claim object to be transformed</param> /// <returns>Collection of <see cref="FormPage"/> objects</returns> public List <FormPage> TransformJ400ToFormPages(J400Claim j400) { var pages = new List <FormPage>(); FormPage page = null; for (int i = 0; i < j400.ServiceLines.Count; i++) { if (i % 10 == 0) { page = new FormPage(); pages.Add(page); page.MasterReference = "j400"; page.ImagePath = this.formImagePath; AddBlock(page, 43, 8, 38, j400.Field12_SubscriberInformation.Line1); AddBlock(page, 43, 9, 38, j400.Field12_SubscriberInformation.Line2); AddBlock(page, 43, 10, 38, j400.Field12_SubscriberInformation.Line3); AddBlock(page, 43, 11, 38, j400.Field12_SubscriberInformation.Line4); AddBlock(page, 43, 13, 10, $"{j400.Field13_SubscriberDateOfBirth:MM/dd/yyyy}"); AddBlock(page, 57, 13, 1, j400.Field14_SubscriberGender_Female ? "X" : string.Empty); AddBlock(page, 60, 13, 1, j400.Field14_SubscriberGender_Male ? "X" : string.Empty); AddBlock(page, 65, 13, 15, j400.Field15_SubscriberId); AddBlock(page, 43, 15, 11, j400.Field16_SubscriberGroupNumber); AddBlock(page, 56, 15, 24, 'X'.Repeat(24)); AddBlock(page, 43, 18, 1, j400.Field18_PatientRelationshipToSubscriber_Self ? "X" : string.Empty); AddBlock(page, 48, 18, 1, j400.Field18_PatientRelationshipToSubscriber_Spouse ? "X" : string.Empty); AddBlock(page, 54, 18, 1, j400.Field18_PatientRelationshipToSubscriber_Dependent ? "X" : string.Empty); AddBlock(page, 63, 18, 1, j400.Field04_OtherDentalOrMedicalCoverage ? "X" : string.Empty); AddBlock(page, 43, 20, 38, j400.Field20_PatientInformation.Line1); AddBlock(page, 43, 21, 38, j400.Field20_PatientInformation.Line2); AddBlock(page, 43, 22, 38, j400.Field20_PatientInformation.Line3); AddBlock(page, 43, 23, 38, j400.Field20_PatientInformation.Line4); AddBlock(page, 43, 25, 10, $"{j400.Field21_PatientDateOfBirth:MM/dd/yyyy}"); AddBlock(page, 57, 25, 1, j400.Field22_PatientGender_Female ? "X" : string.Empty); AddBlock(page, 60, 25, 1, j400.Field22_PatientGender_Male ? "X" : string.Empty); AddBlock(page, 64, 25, 17, j400.Field23_PatientAccountNumber); } decimal y = 29 + (i % 10); var line = j400.ServiceLines[i]; AddBlock(page, 2, y, 10, $"{line.Field24_ProcedureDate:MM/dd/yyyy}"); AddBlock(page, 13, y, 2, line.Field25_AreaOfOralCavity); AddBlock(page, 16, y, 2, line.Field26_ToothSystem); AddBlock(page, 19, y, 11, line.Field27_ToothNumberOrLetter); AddBlock(page, 31, y, 5, line.Field28_ToothSurface); AddBlock(page, 37, y, 5, line.Field29_ProcedureCode); AddBlock(page, 43, y, 31, 'D'.Repeat(31)); string amount = $"{line.Field31_Fee:0.00}".Replace(".", string.Empty); AddBlock(page, 81 - amount.Length, y, amount.Length, amount); // Footer if (i % 10 == 9 || i == j400.ServiceLines.Count - 1) { } } return(pages); }
/// <summary> /// Transforms provided <see cref="Claim"/> to its <see cref="J400Claim"/> representation /// </summary> /// <param name="claim">Claim object to be transformed</param> /// <returns>Resultant <see cref="J400Claim"/> object</returns> public J400Claim TransformClaimToJ400(Claim claim) { var j400 = new J400Claim(); j400.Field12_SubscriberInformation.Line1 = claim.Subscriber.Name.Formatted(); if (claim.Subscriber.Address != null) { j400.Field12_SubscriberInformation.Line2 = claim.Subscriber.Address.Line1; if (!string.IsNullOrEmpty(claim.Subscriber.Address.Line2)) { j400.Field12_SubscriberInformation.Line3 = claim.Subscriber.Address.Line2; j400.Field12_SubscriberInformation.Line4 = claim.Subscriber.Address.Locale; } else { j400.Field12_SubscriberInformation.Line3 = claim.Subscriber.Address.Locale; } } j400.Field13_SubscriberDateOfBirth = claim.Subscriber.DateOfBirth; j400.Field14_SubscriberGender_Female = claim.Subscriber.Gender == Gender.Female; j400.Field14_SubscriberGender_Male = claim.Subscriber.Gender == Gender.Male; j400.Field15_SubscriberId = claim.Subscriber.Name.Identification.Id; j400.Field16_SubscriberGroupNumber = claim.SubscriberInformation.ReferenceIdentification; if (claim.Patient == null) { j400.Field18_PatientRelationshipToSubscriber_Self = true; } else { switch (claim.Patient.Relationship.Code) { case "18": j400.Field18_PatientRelationshipToSubscriber_Self = true; break; case "01": j400.Field18_PatientRelationshipToSubscriber_Spouse = true; break; case "19": j400.Field18_PatientRelationshipToSubscriber_Dependent = true; break; default: j400.Field18_PatientRelationshipToSubscriber_Other = true; break; } } var patient = claim.Patient ?? claim.Subscriber; j400.Field20_PatientInformation.Line1 = patient.Name.Formatted(); if (patient.Address != null) { j400.Field20_PatientInformation.Line2 = patient.Address.Line1; if (!string.IsNullOrEmpty(patient.Address.Line2)) { j400.Field20_PatientInformation.Line3 = patient.Address.Line2; j400.Field20_PatientInformation.Line4 = patient.Address.Locale; } else { j400.Field20_PatientInformation.Line3 = patient.Address.Locale; } } j400.Field21_PatientDateOfBirth = patient.DateOfBirth; j400.Field22_PatientGender_Female = patient.Gender == Gender.Female; j400.Field22_PatientGender_Male = patient.Gender == Gender.Male; j400.Field23_PatientAccountNumber = claim.PatientControlNumber; foreach (var line in claim.ServiceLines) { var j400Line = new J400ServiceLine { Field24_ProcedureDate = line.ServiceDateFrom, Field25_AreaOfOralCavity = string.Join(",", line.OralCavityDesignations.Select(ocd => ocd.Code)), Field27_ToothNumberOrLetter = string.Join(",", line.ToothInformations.Select(ti => ti.ToothCode)), Field28_ToothSurface = string.Join(string.Empty, line.ToothInformations.Select(t => string.Join(string.Empty, t.ToothSurfaces.Select(ts => ts.Code)))), Field29_ProcedureCode = line.Procedure != null ? line.Procedure.ProcedureCode : string.Empty, Field31_Fee = line.ChargeAmount }; j400.ServiceLines.Add(j400Line); } return(j400); }
/// <summary> /// Transforms provided <see cref="Claim"/> object to a collection of <see cref="FormPage"/> /// </summary> /// <param name="claim">Claim object to be transformed</param> /// <returns>Collection of <see cref="FormPage"/> objects</returns> public List <FormPage> TransformClaimToClaimFormFoXml(Claim claim) { J400Claim j400 = this.TransformClaimToJ400(claim); return(this.TransformJ400ToFormPages(j400)); }