protected virtual void HandleVisit(PV1 pv1) { bool doneCreatedVisit; var visit = _persistenceManager.GetVisit(pv1.VisitNumber.IDNumber.Value, pv1.VisitNumber.AssigningAuthority.NamespaceID.Value, true, out doneCreatedVisit); if (visit == null) { return; } visit.Patient = Patient; visit.PatientClass = TryFind <PatientClassEnum>(pv1.PatientClass.Value); visit.AdmissionType = TryFind <AdmissionTypeEnum>(pv1.AdmissionType.Value); visit.VipIndicator = StringToBool(pv1.VIPIndicator.Value); visit.PatientType = TryFind <PatientTypeEnum>(pv1.PatientType.Value); visit.AdmitTime = ParseNullableDateTimeFromDateField(pv1.AdmitDateTime.Time.Value); visit.DischargeTime = ParseNullableDateTimeFromDateField(pv1.GetDischargeDateTime(0).Time.Value); visit.InferVisitStatus(); for (int i = 0; i < pv1.AmbulatoryStatusRepetitionsUsed; ++i) { visit.AmbulatoryStatuses.Add(TryFind <AmbulatoryStatusEnum>(pv1.GetAmbulatoryStatus(i).Value)); } for (int i = 0; i < pv1.AttendingDoctorRepetitionsUsed; ++i) { HandlePractitioner(visit, pv1.GetAttendingDoctor(i), VisitPractitionerRole.AT); } for (int i = 0; i < pv1.ReferringDoctorRepetitionsUsed; ++i) { HandlePractitioner(visit, pv1.GetReferringDoctor(i), VisitPractitionerRole.RF); } for (int i = 0; i < pv1.ConsultingDoctorRepetitionsUsed; ++i) { HandlePractitioner(visit, pv1.GetConsultingDoctor(i), VisitPractitionerRole.CN); } for (int i = 0; i < pv1.AdmittingDoctorRepetitionsUsed; ++i) { HandlePractitioner(visit, pv1.GetConsultingDoctor(i), VisitPractitionerRole.AD); } HandlePatientLocation(visit, pv1); Visit = visit; }
private static void ProducePV1(PV1 pv1, Neusoft.HISFC.Models.RADT.PVisit patientVisit) { pv1.SetIDPV1.Value = "1"; pv1.PatientClass.Value = patientVisit.PatientType.ID.ToString(); pv1.PendingLocation.PointOfCare.Value = patientVisit.PatientLocation.Dept.ID; //pv1.PatientType.Value = patientVisit.PatientType.ID.ToString(); pv1.AssignedPatientLocation.PointOfCare.Value = patientVisit.PatientLocation.Dept.ID; pv1.AssignedPatientLocation.Room.Value = patientVisit.PatientLocation.Room; pv1.AssignedPatientLocation.Bed.Value = patientVisit.PatientLocation.Bed.ID; pv1.AssignedPatientLocation.Building.Value = patientVisit.PatientLocation.Building; pv1.AssignedPatientLocation.Floor.Value = patientVisit.PatientLocation.Floor; pv1.AssignedPatientLocation.LocationDescription.Value = patientVisit.PatientLocation.Dept.Name; //主治医生 XCN attendingDoctor = pv1.GetAttendingDoctor(0); attendingDoctor.IDNumber.Value = patientVisit.AttendingDoctor.ID; attendingDoctor.FamilyLastName.FamilyName.Value = patientVisit.AttendingDoctor.Name.Substring(0, 1); attendingDoctor.GivenName.Value = patientVisit.AttendingDoctor.Name.Substring(1); XCN referringDoctor = pv1.GetReferringDoctor(0); referringDoctor.IDNumber.Value = patientVisit.ReferringDoctor.ID; referringDoctor.FamilyLastName.FamilyName.Value = patientVisit.ReferringDoctor.Name.Substring(0, 1); referringDoctor.GivenName.Value = patientVisit.ReferringDoctor.Name.Substring(1); XCN consultingDoctor = pv1.GetConsultingDoctor(0); consultingDoctor.IDNumber.Value = patientVisit.ConsultingDoctor.ID; consultingDoctor.FamilyLastName.FamilyName.Value = patientVisit.ConsultingDoctor.Name.Substring(0, 1); consultingDoctor.GivenName.Value = patientVisit.ConsultingDoctor.Name.Substring(1); //入院途径 pv1.AdmitSource.Value = patientVisit.AdmitSource.ID; pv1.AdmitDateTime.TimeOfAnEvent.Value = patientVisit.InTime.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture); }
private XCN ParseRole(string role, PV1 pv1) { XCN physician = null; switch (role.ToUpper()) { case "RF": physician = pv1.GetReferringDoctor(0); break; case "AT": physician = pv1.GetAttendingDoctor(0); break; case "CN": physician = pv1.GetConsultingDoctor(0); break; case "AD": physician = pv1.GetConsultingDoctor(0); break; } return(physician); }
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 }