/// <summary> /// Update the NK1 segment /// </summary> private void UpdateNK1(PersonalRelationship subject, NK1 nk1) { if (subject.AlternateIdentifiers != null) { foreach (var altId in subject.AlternateIdentifiers) { UpdateCX(altId, nk1.GetNextOfKinAssociatedPartySIdentifiers(nk1.NextOfKinAssociatedPartySIdentifiersRepetitionsUsed)); } } // Birth time if (subject.BirthTime != null) { MARC.Everest.DataTypes.TS ts = new Everest.DataTypes.TS(subject.BirthTime.Value, ReverseLookup(ComponentUtility.TS_PREC_MAP, subject.BirthTime.Precision)); nk1.DateTimeOfBirth.Time.Value = MARC.Everest.Connectors.Util.ToWireFormat(ts); } if (subject.GenderCode != null) { nk1.AdministrativeSex.Value = subject.GenderCode; } if (subject.LegalName != null) { UpdateXPN(subject.LegalName, nk1.GetName(0)); } if (subject.PerminantAddress != null) { UpdateAD(subject.PerminantAddress, nk1.GetAddress(0)); } if (subject.RelationshipKind != null) { nk1.Relationship.Identifier.Value = subject.RelationshipKind; } if (subject.TelecomAddresses != null) { foreach (var tel in subject.TelecomAddresses) { if (tel.Use == "HP" && tel.Value.StartsWith("tel")) { MessageUtil.XTNFromTel(new TEL() { Value = tel.Value, Use = MARC.Everest.Connectors.Util.Convert <SET <CS <TelecommunicationAddressUse> > >(tel.Use), Capabilities = MARC.Everest.Connectors.Util.Convert <SET <CS <TelecommunicationCabability> > >(tel.Capability) }, nk1.GetContactPersonSTelephoneNumber(nk1.ContactPersonSTelephoneNumberRepetitionsUsed)); } else if (tel.Use == "HP") { nk1.GetPhoneNumber(nk1.ContactPersonSTelephoneNumberRepetitionsUsed).EmailAddress.Value = tel.Value; } else if (tel.Use == "WP" && tel.Value.StartsWith("tel")) { MessageUtil.XTNFromTel(new TEL() { Value = tel.Value, Use = MARC.Everest.Connectors.Util.Convert <SET <CS <TelecommunicationAddressUse> > >(tel.Use), Capabilities = MARC.Everest.Connectors.Util.Convert <SET <CS <TelecommunicationCabability> > >(tel.Capability) }, nk1.GetContactPersonSTelephoneNumber(nk1.ContactPersonSTelephoneNumberRepetitionsUsed)); } else if (tel.Use == "WP") { nk1.GetPhoneNumber(nk1.ContactPersonSTelephoneNumberRepetitionsUsed).EmailAddress.Value = tel.Value; } } } }
/// <summary> /// Creates a HL Message out of an object model /// </summary> /// <param name="objToEncode"></param> /// <returns></returns> public String Encode(Patient objToEncode) { var patient = objToEncode; PipeParser parser = new PipeParser(); // HL7 Message Header Settings ADT_A04 qry = new ADT_A04(); qry.MSH.MessageType.MessageType.Value = "ADT"; qry.MSH.MessageType.TriggerEvent.Value = "A01"; qry.MSH.FieldSeparator.Value = "|"; qry.MSH.VersionID.Value = "2.3"; qry.MSH.SendingApplication.NamespaceID.Value = "CohieCentral"; qry.MSH.SendingFacility.NamespaceID.Value = "COHIE"; qry.MSH.ReceivingApplication.NamespaceID.Value = "Clinical Data Provider"; qry.MSH.EncodingCharacters.Value = @"^~\&"; qry.MSH.DateTimeOfMessage.TimeOfAnEvent.SetLongDate(DateTime.Now); qry.MSH.ProcessingID.ProcessingID.Value = "P"; qry.PID.SetIDPatientID.Value = "77291"; qry.PID.PatientIDExternalID.CheckDigit.Value = "9"; qry.PID.PatientIDExternalID.ID.Value = "PATID1234"; qry.PID.PatientIDExternalID.CodeIdentifyingTheCheckDigitSchemeEmployed.Value = "55A"; // Patient Name qry.PID.GetPatientName(0).GivenName.Value = patient.PersonName.GivenName; qry.PID.GetPatientName(0).FamilyName.Value = patient.PersonName.FamilyName; qry.PID.GetPatientName(0).SuffixEgJRorIII.Value = patient.PersonName.Suffix; qry.PID.Sex.Value = patient.PersonSex.ToString(); qry.PID.GetPhoneNumberHome(0).PhoneNumber.Value = patient.PersonNumber.HomeNumber; qry.PID.DateOfBirth.TimeOfAnEvent.Value = "19680219"; // Patient Address qry.PID.GetPatientAddress(0).StreetAddress.Value = patient.PersonAddress.StreetAddress; qry.PID.GetPatientAddress(0).City.Value = patient.PersonAddress.City; qry.PID.GetPatientAddress(0).StateOrProvince.Value = patient.PersonAddress.State; qry.PID.GetPatientAddress(0).ZipOrPostalCode.Value = patient.PersonAddress.ZipCode; // Kin Details qry.AddNK1(); NK1 objNextOfKin = qry.GetNK1(); Person objKin = patient.NextOfKin[0]; objNextOfKin.GetName(0).GivenName.Value = objKin.PersonName.GivenName; objNextOfKin.GetName(0).FamilyName.Value = objKin.PersonName.FamilyName; objNextOfKin.Relationship.Identifier.Value = objKin.Relationship; objNextOfKin.GetAddress(0).StreetAddress.Value = objKin.PersonAddress.StreetAddress; objNextOfKin.GetAddress(0).City.Value = objKin.PersonAddress.City; objNextOfKin.GetAddress(0).StateOrProvince.Value = objKin.PersonAddress.State; objNextOfKin.GetAddress(0).ZipOrPostalCode.Value = objKin.PersonAddress.ZipCode; objNextOfKin.GetPhoneNumber(0).PhoneNumber.Value = objKin.PersonNumber.HomeNumber; objNextOfKin.GetBusinessPhoneNumber(0).PhoneNumber.Value = objKin.PersonNumber.OfficeNumber; var message = parser.Encode(qry); return(message); }