/** * Returns a single repetition of Primary Observer Address(PEO-20). * @param rep the repetition number (this is a repeating field) * @throws HL7Exception if the repetition number is invalid. */ public XAD getPrimaryObserverAddress(int rep) { XAD ret = null; try { Type t = this.getField(20, rep); ret = (XAD)t; } catch (System.Exception ex) { HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", ex); throw new System.Exception("An unexpected error ocurred", ex); } return(ret); }
/// <summary> /// Returns a single repetition of Location Address(LOC-5). throws HL7Exception if the repetition /// number is invalid. /// </summary> /// /// <exception cref="Exception"> Thrown when an exception error condition occurs. </exception> /// /// <param name="rep"> The repetition number (this is a repeating field) </param> /// /// <returns> The location address. </returns> public XAD GetLocationAddress(int rep) { XAD ret = null; try { IType t = this.GetField(5, rep); ret = (XAD)t; } catch (System.Exception ex) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex); throw new System.Exception("An unexpected error ocurred", ex); } return(ret); }
/// <summary> Returns a single repetition of Contact Person's Address (NK1-32).</summary> /// <param name="rep">the repetition number (this is a repeating field) /// </param> /// <throws> HL7Exception if the repetition number is invalid. </throws> public virtual XAD getContactPersonSAddress(int rep) { XAD ret = null; try { Type t = this.getField(32, rep); ret = (XAD)t; } catch (System.InvalidCastException) { throw new Exception(); } return(ret); }
/// <summary> Returns a single repetition of Primary Observer Address (PEO-20).</summary> /// <param name="rep">the repetition number (this is a repeating field) /// </param> /// <throws> HL7Exception if the repetition number is invalid. </throws> public virtual XAD getPrimaryObserverAddress(int rep) { XAD ret = null; try { Type t = this.getField(20, rep); ret = (XAD)t; } catch (System.InvalidCastException) { throw new Exception(); } return(ret); }
/// <summary> Returns a single repetition of Insured's Employer's Address (IN1-44).</summary> /// <param name="rep">the repetition number (this is a repeating field) /// </param> /// <throws> HL7Exception if the repetition number is invalid. </throws> public virtual XAD getInsuredSEmployerSAddress(int rep) { XAD ret = null; try { Type t = this.getField(44, rep); ret = (XAD)t; } catch (System.InvalidCastException) { throw new Exception(); } return(ret); }
/// <summary> Returns a single repetition of Address of Outside Site(s) (OM1-28).</summary> /// <param name="rep">the repetition number (this is a repeating field) /// </param> /// <throws> HL7Exception if the repetition number is invalid. </throws> public virtual XAD getAddressOfOutsideSiteS(int rep) { XAD ret = null; try { Type t = this.getField(28, rep); ret = (XAD)t; } catch (System.InvalidCastException) { throw new Exception(); } return(ret); }
/// <summary> Returns a single repetition of Signature Authority Address (FAC-11).</summary> /// <param name="rep">the repetition number (this is a repeating field) /// </param> /// <throws> HL7Exception if the repetition number is invalid. </throws> public virtual XAD getSignatureAuthorityAddress(int rep) { XAD ret = null; try { Type t = this.getField(11, rep); ret = (XAD)t; } catch (System.InvalidCastException) { throw new Exception(); } return(ret); }
/// <summary> Returns a single repetition of Ordering Provider Address (ORC-24).</summary> /// <param name="rep">the repetition number (this is a repeating field) /// </param> /// <throws> HL7Exception if the repetition number is invalid. </throws> public virtual XAD getOrderingProviderAddress(int rep) { XAD ret = null; try { Type t = this.getField(24, rep); ret = (XAD)t; } catch (System.InvalidCastException) { throw new Exception(); } return(ret); }
/// <summary> Returns a single repetition of Office/Home Address/Birthplace (ROL-11).</summary> /// <param name="rep">the repetition number (this is a repeating field) /// </param> /// <throws> HL7Exception if the repetition number is invalid. </throws> public virtual XAD getOfficeHomeAddressBirthplace(int rep) { XAD ret = null; try { Type t = this.getField(11, rep); ret = (XAD)t; } catch (System.InvalidCastException) { throw new Exception(); } return(ret); }
/// <summary> Returns a single repetition of Event Location Occurred Address (PEO-7).</summary> /// <param name="rep">the repetition number (this is a repeating field) /// </param> /// <throws> HL7Exception if the repetition number is invalid. </throws> public virtual XAD getEventLocationOccurredAddress(int rep) { XAD ret = null; try { Type t = this.getField(7, rep); ret = (XAD)t; } catch (System.InvalidCastException) { throw new Exception(); } return(ret); }
///<summary> /// Returns all repetitions of Signature Authority Address (FAC-11). ///</summary> public XAD[] GetSignatureAuthorityAddress() { XAD[] ret = null; try { IType[] t = this.GetField(11); ret = new XAD[t.Length]; for (int i = 0; i < ret.Length; i++) { ret[i] = (XAD)t[i]; } } catch (HL7Exception he) { HapiLogFactory.GetHapiLog(this.GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he); throw new System.Exception("An unexpected error ocurred", he); } catch (System.Exception cce) { HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", cce); throw new System.Exception("An unexpected error ocurred", cce); } return ret; }
public void TestUpdateADCityOnly() { var actual = new XAD(this.genericMessage); this.entityAddress.Component = new List <EntityAddressComponent> { new EntityAddressComponent(AddressComponentKeys.City, "Hamilton") }; NotifierBase.UpdateAD(entityAddress, actual); Assert.AreEqual("Hamilton", actual.City.Value); Assert.AreEqual(string.Empty, actual.Country.Value); Assert.AreEqual(string.Empty, actual.ZipOrPostalCode.Value); Assert.AreEqual(string.Empty, actual.StateOrProvince.Value); Assert.AreEqual(string.Empty, actual.StreetAddress.Value); }
/// <summary> /// Creates an AustralianAddress instance from an XAD instance. /// </summary> /// <param name="name">The HL7 V2 XAD instance.</param> /// <returns></returns> internal static IAddress GetAustralianAddress(XAD xad) { AustralianState addressState; var addressStateSpecified = Enum.TryParse(xad.stateorprovince, out addressState); var address = BaseCDAModel.CreateAddress(); address.AustralianAddress = BaseCDAModel.CreateAustralianAddress(); address.AustralianAddress.PostCode = xad.ziporpostalcode; address.AustralianAddress.UnstructuredAddressLines = new List <string> { xad.streetaddress }; address.AustralianAddress.SuburbTownLocality = xad.city; address.AustralianAddress.State = AustralianState.QLD; if (addressStateSpecified) { address.AustralianAddress.State = addressState; } address.AddressPurpose = AddressPurpose.NotStatedUnknownInadequatelyDescribed; switch (xad.addresstype) { case "H": case "P": case "BR": address.AddressPurpose = AddressPurpose.Residential; break; case "B": case "RH": case "O": case "L": address.AddressPurpose = AddressPurpose.Business; break; case "M": address.AddressPurpose = AddressPurpose.MailingOrPostal; break; case "C": address.AddressPurpose = AddressPurpose.TemporaryAccommodation; break; } return(address); }
/** * Returns all repetitions of Filler Contact Address (SCH-18). */ public XAD[] getFillerContactAddress() { XAD[] ret = null; try { Type[] t = this.getField(18); ret = new XAD[t.Length]; for (int i = 0; i < ret.Length; i++) { ret[i] = (XAD)t[i]; } } catch (HL7Exception he) { HapiLogFactory.getHapiLog(this.GetType()).error("Unexpected problem obtaining field value. This is a bug.", he); throw new System.Exception("An unexpected error ocurred", he); } catch (System.Exception cce) { HapiLogFactory.getHapiLog(GetType()).error("Unexpected problem obtaining field value. This is a bug.", cce); throw new System.Exception("An unexpected error ocurred", cce); } return(ret); }
/// <summary> Returns all repetitions of Office/Home Address/Birthplace (ROL-11).</summary> public virtual XAD[] getOfficeHomeAddressBirthplace() { XAD[] ret = null; try { Type[] t = this.getField(11); ret = new XAD[t.Length]; for (int i = 0; i < ret.Length; i++) { ret[i] = (XAD)t[i]; } } catch (System.InvalidCastException) { throw new Exception(); } catch (NuGenHL7Exception) { throw new Exception(); } return(ret); }
/// <summary> Returns all repetitions of Address of Outside Site(s) (OM1-28).</summary> public virtual XAD[] getAddressOfOutsideSiteS() { XAD[] ret = null; try { Type[] t = this.getField(28); ret = new XAD[t.Length]; for (int i = 0; i < ret.Length; i++) { ret[i] = (XAD)t[i]; } } catch (System.InvalidCastException) { throw new Exception(); } catch (NuGenHL7Exception) { throw new Exception(); } return(ret); }
/// <summary> Returns all repetitions of Event Location Occurred Address (PEO-7).</summary> public virtual XAD[] getEventLocationOccurredAddress() { XAD[] ret = null; try { Type[] t = this.getField(7); ret = new XAD[t.Length]; for (int i = 0; i < ret.Length; i++) { ret[i] = (XAD)t[i]; } } catch (System.InvalidCastException) { throw new Exception(); } catch (NuGenHL7Exception) { throw new Exception(); } return(ret); }
/// <summary> /// Returns all repetitions of Patient Address (PID-11). /// /// </summary> public XAD[] GetPatientAddress() { XAD[] xadArray; try { IType[] field = this.GetField(11); xadArray = new XAD[field.Length]; for (int index = 0; index < xadArray.Length; ++index) { xadArray[index] = (XAD)field[index]; } } catch (HL7Exception ex) { HapiLogFactory.GetHapiLog(this.GetType()).Error((object)"Unexpected problem obtaining field value. This is a bug.", (Exception)ex); throw new Exception("An unexpected error ocurred", (Exception)ex); } catch (Exception ex) { HapiLogFactory.GetHapiLog(this.GetType()).Error((object)"Unexpected problem obtaining field value. This is a bug.", ex); throw new Exception("An unexpected error ocurred", ex); } return(xadArray); }
/// <summary> /// Converts an <see cref="XAD"/> address instance to an <see cref="EntityAddress"/> instance. /// </summary> /// <param name="address">The address to be converted.</param> /// <returns>Returns the converted entity address.</returns> public static EntityAddress ConvertAddress(XAD address) { return(MessageUtil.ConvertAddresses(new XAD[] { address }).FirstOrDefault()); }
private void button1_Click(object sender, EventArgs e) { ORM_O01 orm = new ORM_O01(); #region 组装消息头 orm.MSH.MessageType.MessageType.Value = "ORM"; orm.MSH.MessageType.TriggerEvent.Value = "O01"; orm.MSH.MessageType.MessageStructure.Value = "ORM_O01"; orm.MSH.FieldSeparator.Value = MessageConstant.FieldSeparator; orm.MSH.SendingApplication.NamespaceID.Value = "SSMZ1"; orm.MSH.SendingFacility.NamespaceID.Value = "SSMZ1"; orm.MSH.ReceivingApplication.NamespaceID.Value = "MediII"; orm.MSH.ReceivingFacility.NamespaceID.Value = "MediII"; orm.MSH.EncodingCharacters.Value = MessageConstant.EncodingCharacters; orm.MSH.VersionID.VersionID.Value = MessageConstant.VersionID; orm.MSH.DateTimeOfMessage.TimeOfAnEvent.SetLongDateWithSecond(DateTime.Now); orm.MSH.MessageControlID.Value = MediII.Common.GUIDHelper.NewGUID(); orm.MSH.ProcessingID.ProcessingID.Value = MessageConstant.ProcessingID; #endregion for (int i = 0; i < messageList.Count; i++) { MessageNode node = messageList[i]; #region 组装PID段 PID pid = orm.PATIENT.PID; pid.PatientID.ID.Value = node.PIDList["PatientIdentifier"]; pid.GetPatientIdentifierList(0).ID.Value = node.PIDList["PatientIdentifier"]; pid.GetPatientIdentifierList(1).ID.Value = node.PIDList["jiuzhenkh"]; pid.GetPatientIdentifierList(2).ID.Value = node.PIDList["binganhao"]; pid.GetPatientIdentifierList(3).ID.Value = node.PIDList["shebaokh"]; pid.GetPatientIdentifierList(4).ID.Value = node.PIDList["gongfeizh"]; string bingRenXM = node.PIDList["bingrenxm"]; #region 姓名转全拼 StringBuilder sb = new StringBuilder(); foreach (char c in bingRenXM) { if (ChineseChar.IsValidChar(c)) { ChineseChar pinYinConvert = new ChineseChar(c); string pinYin = pinYinConvert.Pinyins[0]; if (!string.IsNullOrEmpty(pinYin)) { string word = pinYin.Substring(0, pinYin.Length - 1); //首字母大写,其他小写 StringBuilder sbW = new StringBuilder(word.Length); for (int n = 0; n < word.Length; n++) { string s = word.Substring(n, 1); if (n == 0) { sbW.Append(s.ToUpper()); } else { sbW.Append(s.ToLower()); } } sb.Append(sbW.ToString()); } } else { sb.Append(c); } } #endregion pid.GetPatientName(0).FamilyName.Surname.Value = sb.ToString(); pid.GetPatientName(0).GivenName.Value = bingRenXM; DateTime dtCHUSHENGRQ = DateTime.Parse(node.PIDList["chushengrq"]); pid.DateTimeOfBirth.TimeOfAnEvent.SetLongDateWithSecond((DateTime)dtCHUSHENGRQ);//出生日期 //if (string.IsNullOrEmpty(bingRenXx.XINGBIE)) //性别 // pid.AdministrativeSex.Value = "O"; //else if (bingRenXx.XINGBIE == "男") // pid.AdministrativeSex.Value = "M"; //else if (bingRenXx.XINGBIE == "女") pid.AdministrativeSex.Value = node.PIDList["sex"]; XAD address = pid.GetPatientAddress(0); address.City.Value = node.PIDList["city"]; address.StateOrProvince.Value = node.PIDList["province"]; address.StreetAddress.StreetOrMailingAddress.Value = node.PIDList["streetaddress"]; address.ZipOrPostalCode.Value = node.PIDList["postcode"]; address.OtherDesignation.Value = node.PIDList["postcode"]; pid.GetPhoneNumberHome(0).PhoneNumber.Value = node.PIDList["homephone"]; pid.GetPhoneNumberBusiness(0).PhoneNumber.Value = node.PIDList["workphone"]; pid.MaritalStatus.Text.Value = node.PIDList["hunyin"]; string hunYinDm = string.Empty; //if (bingRenXx.HUNYINDM == "0") // hunYinDm = "S"; //else if (bingRenXx.HUNYINDM == "1") // hunYinDm = "M"; //else hunYinDm = "O"; //婚姻代码 pid.MaritalStatus.Identifier.Value = hunYinDm; //婚姻代码 pid.PatientAccountNumber.ID.Value = node.PIDList["yibaokh"]; pid.SSNNumberPatient.Value = node.PIDList["idnumber"]; pid.GetEthnicGroup(0).Identifier.Value = node.PIDList["EthicGroupID"]; pid.GetEthnicGroup(0).Text.Value = node.PIDList["EthicGroupName"]; pid.BirthPlace.Value = node.PIDList["BirthPlace"]; pid.Nationality.Identifier.Value = node.PIDList["NationalityID"]; pid.Nationality.Text.Value = node.PIDList["NationalityName"]; #endregion #region 组装PV1 PV1 pv1 = orm.PATIENT.PATIENT_VISIT.PV1; string menZhenZhuYuanBZ = node.PV1List["menZhenZhuYuanBZ"]; if (menZhenZhuYuanBZ == "0") { //门诊 pv1.SetIDPV1.Value = node.PV1List["SetID"]; pv1.AdmissionType.Value = "R"; pv1.PatientClass.Value = "O"; //门诊O pv1.GetAttendingDoctor(0).IDNumber.Value = node.PV1List["AdmittingDoctorID"]; pv1.HospitalService.Value = node.PV1List["HospitalService"]; pv1.PatientType.Value = node.PV1List["PatientType"]; pv1.VisitNumber.ID.Value = node.PV1List["VisitNumber"]; pv1.ServicingFacility.Value = node.PV1List["ServicingFacility"]; //上下午标志 0-上午,1-下午,2-晚上 pv1.PendingLocation.PointOfCare.Value = node.PV1List["PendingLocation"]; DateTime dtZHIDANRQ = DateTime.Parse(node.PV1List["AdmitDate"]); pv1.AdmitDateTime.TimeOfAnEvent.SetLongDateWithSecond((DateTime)dtZHIDANRQ);//制单医生日期 就诊日期 pv1.VisitIndicator.Value = "V"; pv1.ChargePriceIndicator.Value = node.PV1List["ChargePriceIndicator"]; } else { //住院 pid.GetPatientIdentifierList(1).ID.Value = node.PIDList["jiuzhenkh"]; pid.GetAlternatePatientIDPID(0).ID.Value = node.PIDList["yingerbz"];//婴儿标志0非婴儿1婴儿 pid.GetMotherSIdentifier(0).ID.Value = node.PIDList["MothersIdentifier"]; pv1.VisitNumber.ID.Value = node.PV1List["VisitNumber"]; pv1.SetIDPV1.Value = node.PV1List["AlternateVisitID"]; //住医生院次数 pv1.PatientClass.Value = "I"; //住院病人 pv1.AssignedPatientLocation.PointOfCare.Value = node.PV1List["PointOfCare"]; pv1.AssignedPatientLocation.Bed.Value = node.PV1List["Bed"]; pv1.AssignedPatientLocation.Room.Value = node.PV1List["Room"]; if (!String.IsNullOrEmpty(node.PV1List["Facility"]))//当前科室,当前科室名称 { pv1.AssignedPatientLocation.Facility.NamespaceID.Value = node.PV1List["Facility"]; } pv1.GetAttendingDoctor(0).IDNumber.Value = node.PV1List["AttendingDoctorID"]; pv1.GetAttendingDoctor(0).GivenName.Value = node.PV1List["AttendingDoctorFamilyName"]; DateTime dtRuYuanRQ = DateTime.Parse(node.PV1List["AdmitDate"]); pv1.AdmitDateTime.TimeOfAnEvent.SetLongDateWithSecond((DateTime)dtRuYuanRQ); //入院日期 pv1.PendingLocation.PointOfCare.Value = node.PV1List["PendingLocation"]; //当前科室 pv1.PatientType.Value = node.PV1List["PatientType"]; //费用类别 DateTime dtRuKeRQ = DateTime.Parse(node.PV1List["AdmitDate"]); if (dtRuKeRQ != null) { pv1.GetContractEffectiveDate(0).Value = ((DateTime)dtRuKeRQ).ToString("yyyyMMddHHmmss");//入科日期 } pv1.VisitIndicator.Value = "V"; pv1.ChargePriceIndicator.Value = node.PV1List["ChargePriceIndicator"]; pv1.AlternateVisitID.ID.Value = node.PV1List["AlternateVisitID"];//住院次数 } #endregion #region 组装检验申请内容 for (int j = 0; j < node.ORCList.Count; j++) { ORC orc = orm.GetORDER(j).ORC; orc.OrderControl.Value = "SC"; orc.PlacerOrderNumber.EntityIdentifier.Value = node.ORCList[j]["PlacerOrderNumber"]; //申请单ID orc.FillerOrderNumber.EntityIdentifier.Value = node.ORCList[j]["FillterOrderNumber"]; //检查号 orc.OrderStatus.Value = "SC"; orc.DateTimeOfTransaction.TimeOfAnEvent.SetLongDateWithSecond(DateTime.Parse(node.ORCList[j]["DateTimeOfTransaction"])); //登记时间 orc.GetEnteredBy(0).IDNumber.Value = node.ORCList[j]["EnteredBy"]; //录入者 orc.EnteringOrganization.Identifier.Value = node.ORCList[j]["EnteringOrganizationIdentifier"]; //申请科室ID orc.EnteringOrganization.Text.Value = node.ORCList[j]["EnteringOrganizationText"]; //申请科室名称 orc.GetOrderingProvider(j).IDNumber.Value = node.ORCList[j]["OrderingProviderID"]; //申请医生ID orc.GetOrderingProvider(j).GivenName.Value = node.ORCList[j]["OrderingProviderName"]; //申请医生姓名 orc.OrderControlCodeReason.Text.Value = node.ORCList[j]["OrderControlCodeReason"]; //检查目的 OBR obr = orm.GetORDER(j).ORDER_DETAIL.OBR; obr.SetIDOBR.Value = (j + 1).ToString(); obr.PlacerOrderNumber.EntityIdentifier.Value = node.OBRList[j]["PlacerOrderNumber"]; //申请单ID obr.FillerOrderNumber.EntityIdentifier.Value = node.OBRList[j]["FillterOrderNumber"]; //检查号 obr.UniversalServiceIdentifier.Identifier.Value = node.OBRList[j]["UniversalServiceIdentifier"]; //检查部位ID obr.UniversalServiceIdentifier.Text.Value = node.OBRList[j]["UniversalServiceText"]; //检查部位名称 obr.Priority.Value = node.OBRList[j]["Priority"]; //优先级 obr.DangerCode.Identifier.Value = node.OBRList[j]["DangerCodeIdentifier"];; //执行科室 obr.DangerCode.Text.Value = node.OBRList[j]["DangerCodeText"]; //执行科室名称 } #endregion } #region 转换消息对象为字符串 NHapi.Base.Parser.PipeParser parser = new PipeParser(); message = parser.Encode(orm); this.txtOutput.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); this.txtOutput.AppendText("构建消息内容完成,消息内容如下:"); this.txtOutput.AppendText(System.Environment.NewLine); this.txtOutput.AppendText(message); this.txtOutput.AppendText(System.Environment.NewLine); #endregion }
/// <summary> /// Converts the specified HL7v2 XAD to an entity address /// </summary> /// <param name="address">The address to be converted</param> /// <returns>The converted entity address</returns> public static EntityAddress ToModel(this XAD address) { return(new XAD[] { address }.ToModel().FirstOrDefault()); }