Пример #1
0
 private void ORC()
 {
     seg = new SegmentHL7(SegmentName.ORC);
     seg.SetField(0, "ORC");
     seg.SetField(1, "RE");           //fixed
     msg.Segments.Add(seg);
 }
Пример #2
0
		///<summary>Patient visit.</summary>
		private void PV1(long aptNum,long provNum){
			seg=new SegmentHL7(SegmentNameHL7.PV1);
			seg.SetField(0,"PV1");
			Provider prov=Providers.GetProv(provNum);
			seg.SetField(7,prov.EcwID,prov.LName,prov.FName,prov.MI);
			seg.SetField(19,aptNum.ToString());
			msg.Segments.Add(seg);
		}
		///<summary>Returns null if there is no DFT defined for the enabled HL7Def.</summary>
		public static MessageHL7 GenerateDFT(List<Procedure> procList,EventTypeHL7 eventType,Patient pat,Patient guar,long aptNum,string pdfDescription,string pdfDataString) {//add event (A04 etc) parameters later if needed
			//In \\SERVERFILES\storage\OPEN DENTAL\Programmers Documents\Standards (X12, ADA, etc)\HL7\Version2.6\V26_CH02_Control_M4_JAN2007.doc
			//On page 28, there is a Message Construction Pseudocode as well as a flowchart which might help.
			Provider prov=Providers.GetProv(Patients.GetProvNum(pat));
			Appointment apt=Appointments.GetOneApt(aptNum);
			MessageHL7 messageHL7=new MessageHL7(MessageTypeHL7.DFT);
			HL7Def hl7Def=HL7Defs.GetOneDeepEnabled();
			if(hl7Def==null) {
				return null;
			}
			//find a DFT message in the def
			HL7DefMessage hl7DefMessage=null;
			for(int i=0;i<hl7Def.hl7DefMessages.Count;i++) {
				if(hl7Def.hl7DefMessages[i].MessageType==MessageTypeHL7.DFT) {
					hl7DefMessage=hl7Def.hl7DefMessages[i];
					//continue;
					break;
				}
			}
			if(hl7DefMessage==null) {//DFT message type is not defined so do nothing and return
				return null;
			}
			for(int s=0;s<hl7DefMessage.hl7DefSegments.Count;s++) {
				int countRepeat=1;
				if(hl7DefMessage.hl7DefSegments[s].SegmentName==SegmentNameHL7.FT1) {
					countRepeat=procList.Count;
				}
				//for example, countRepeat can be zero in the case where we are only sending a PDF of the TP to eCW, and no procs.
				for(int repeat=0;repeat<countRepeat;repeat++) {//FT1 is optional and can repeat so add as many FT1's as procs in procList
					//if(hl7DefMessage.hl7DefSegments[s].SegmentName==SegmentNameHL7.FT1) {
					if(hl7DefMessage.hl7DefSegments[s].SegmentName==SegmentNameHL7.FT1 && procList.Count>repeat) {
						prov=Providers.GetProv(procList[repeat].ProvNum);
					}
					SegmentHL7 seg=new SegmentHL7(hl7DefMessage.hl7DefSegments[s].SegmentName);
					seg.SetField(0,hl7DefMessage.hl7DefSegments[s].SegmentName.ToString());
					for(int f=0;f<hl7DefMessage.hl7DefSegments[s].hl7DefFields.Count;f++) {
						string fieldName=hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FieldName;
						if(fieldName=="") {//If fixed text instead of field name just add text to segment
							seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos,hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FixedText);
						}
						else {
							//seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos,
							//FieldConstructor.GenerateDFT(hl7Def,fieldName,pat,prov,procList[repeat],guar,apt,repeat+1,eventType,pdfDescription,pdfDataString));
							Procedure proc=null;
							if(procList.Count>repeat) {//procList could be an empty list
								proc=procList[repeat];
							}
							seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos,
								FieldConstructor.GenerateDFT(hl7Def,fieldName,pat,prov,proc,guar,apt,repeat+1,eventType,pdfDescription,pdfDataString));
						}
					}
					messageHL7.Segments.Add(seg);
				}
			}
			return messageHL7;
		}
Пример #4
0
        ///<summary>Patient visit.</summary>
        private void PV1(long aptNum, long provNum)
        {
            seg = new SegmentHL7(SegmentNameHL7.PV1);
            seg.SetField(0, "PV1");
            Provider prov = Providers.GetProv(provNum);

            seg.SetField(7, prov.EcwID, prov.LName, prov.FName, prov.MI);
            seg.SetField(19, aptNum.ToString());
            msg.Segments.Add(seg);
        }
Пример #5
0
 ///<summary>Type CE.  Writes a coded element into the fieldIndex field of the current segment.</summary>
 private void WriteCE(int fieldIndex, string strIdentifier, string strText, string strNameCodeSystem)
 {
     _seg.SetField(fieldIndex,
                   strIdentifier,    //CE.1 Identifier.  Required (length 1..20).
                   strText,          //CE.2 Text.  Required if known (length 1..199).  Standardized description associated with CE.1.
                   strNameCodeSystem //CE.3 Name of Coding System.  Required (length 1..20).
                                     //CE.4 Alternate Identifier.  No longer used.
                                     //CE.5 Alternate Text.  No longer used.
                                     //CE.6 Name of Alternate Coding system.  No longer used.
                   );
 }
Пример #6
0
        ///<summary>Returns null if no HL7 def is enabled or no ACK is defined in the enabled def.</summary>
        public static MessageHL7 GenerateACK(string controlId, bool isAck, string ackEvent)
        {
            MessageHL7 messageHL7 = new MessageHL7(MessageTypeHL7.ACK);

            messageHL7.ControlId = controlId;
            messageHL7.AckEvent  = ackEvent;
            HL7Def hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);               //no def enabled, return null
            }
            //find an ACK message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.ACK && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    break;
                }
            }
            if (hl7DefMessage == null)           //ACK message type is not defined so do nothing and return
            {
                return(null);
            }
            //go through each segment in the def
            for (int s = 0; s < hl7DefMessage.hl7DefSegments.Count; s++)
            {
                SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[s].SegmentName);
                seg.SetField(0, hl7DefMessage.hl7DefSegments[s].SegmentName.ToString());
                for (int f = 0; f < hl7DefMessage.hl7DefSegments[s].hl7DefFields.Count; f++)
                {
                    string fieldName = hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FieldName;
                    if (fieldName == "")                   //If fixed text instead of field name just add text to segment
                    {
                        seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos, hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FixedText);
                    }
                    else
                    {
                        seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos, FieldConstructor.GenerateACK(hl7Def, fieldName, controlId, isAck, ackEvent));
                    }
                }
                messageHL7.Segments.Add(seg);
            }
            return(messageHL7);
        }
Пример #7
0
Файл: EhrORU.cs Проект: mnisl/OD
		///<summary>Patient identification.</summary>
		private void PID(Patient pat){
			seg=new SegmentHL7(SegmentNameHL7.PID);
			seg.SetField(0,"PID");
			seg.SetField(2,pat.PatNum.ToString());
			seg.SetField(3,pat.PatNum.ToString());
			seg.SetField(5,pat.LName,pat.FName);
			if(pat.Birthdate.Year>1880) {//7: dob optional
				seg.SetField(7,pat.Birthdate.ToString("yyyyMMdd"));
			}
			seg.SetField(8,ConvertGender(pat.Gender));
			seg.SetField(10,ConvertRace(PatientRaces.GetPatientRaceOldFromPatientRaces(pat.PatNum)));//Converts entries from PatientRace table to deprecated PatientRaceOld for call.
			seg.SetField(11,pat.Address,pat.Address2,pat.City,pat.State,pat.Zip,"","M");//M is for mailing.
			seg.SetField(13,ConvertPhone(pat.HmPhone));
			seg.SetField(22,ConvertEthnicGroup(PatientRaces.GetPatientRaceOldFromPatientRaces(pat.PatNum)));//Converts entries from PatientRace table to deprecated PatientRaceOld for call.
			msg.Segments.Add(seg);
		}
Пример #8
0
		///<summary>Event Type segment.  Used to communicate trigger event information to receiving applications.  Guide page 38.</summary>
		private void EVN() {
			_seg=new SegmentHL7(SegmentNameHL7.EVN);
			_seg.SetField(0,"EVN");
			//EVN-1 Event Type Code.  No longer used.
			_seg.SetField(2,DateTime.Now.ToString("yyyyMMddHHmmss"));//EVN-2 Recorded Date/Time.  Required (length 12..26).
			//EVN-3 Date/Time Planned Event.  No longer used.
			//EVN-4 Event Reason Code.  No longer used.
			//EVN-5 Operator ID.  No longer used.
			//EVN-6 Event Occurred.  No longer used.
			//EVN-7 Event Facility.  Required (length 1..241).  This is the location where the patient received treatment.
			_seg.SetField(7,
				_sendingFacilityName,//EVN-7.1 Namespace ID.  The name of the originating facility.
				_sendingFacilityNpi,//EVN-7.2 Universal ID.  Suggested value is NPI.
				"NPI"//EVN-7.3 Universal ID Type.
			);
			_msg.Segments.Add(_seg);
		}
Пример #9
0
 ///<summary>Patient identification.</summary>
 private void PID(Patient pat)
 {
     seg = new SegmentHL7(SegmentNameHL7.PID);
     seg.SetField(0, "PID");
     seg.SetField(2, pat.PatNum.ToString());
     seg.SetField(3, pat.PatNum.ToString());
     seg.SetField(5, pat.LName, pat.FName);
     if (pat.Birthdate.Year > 1880)           //7: dob optional
     {
         seg.SetField(7, pat.Birthdate.ToString("yyyyMMdd"));
     }
     seg.SetField(8, ConvertGender(pat.Gender));
     seg.SetField(10, ConvertRace(PatientRaces.GetPatientRaceOldFromPatientRaces(pat.PatNum)));        //Converts entries from PatientRace table to deprecated PatientRaceOld for call.
     seg.SetField(11, pat.Address, pat.Address2, pat.City, pat.State, pat.Zip, "", "M");               //M is for mailing.
     seg.SetField(13, ConvertPhone(pat.HmPhone));
     seg.SetField(22, ConvertEthnicGroup(PatientRaces.GetPatientRaceOldFromPatientRaces(pat.PatNum))); //Converts entries from PatientRace table to deprecated PatientRaceOld for call.
     msg.Segments.Add(seg);
 }
Пример #10
0
 ///<summary>Event Type segment.  Used to communicate trigger event information to receiving applications.  Guide page 38.</summary>
 private void EVN()
 {
     _seg = new SegmentHL7(SegmentNameHL7.EVN);
     _seg.SetField(0, "EVN");
     //EVN-1 Event Type Code.  No longer used.
     _seg.SetField(2, DateTime.Now.ToString("yyyyMMddHHmmss"));           //EVN-2 Recorded Date/Time.  Required (length 12..26).
     //EVN-3 Date/Time Planned Event.  No longer used.
     //EVN-4 Event Reason Code.  No longer used.
     //EVN-5 Operator ID.  No longer used.
     //EVN-6 Event Occurred.  No longer used.
     //EVN-7 Event Facility.  Required (length 1..241).  This is the location where the patient received treatment.
     _seg.SetField(7,
                   _sendingFacilityName, //EVN-7.1 Namespace ID.  The name of the originating facility.
                   _sendingFacilityNpi,  //EVN-7.2 Universal ID.  Suggested value is NPI.
                   "NPI"                 //EVN-7.3 Universal ID Type.
                   );
     _msg.Segments.Add(_seg);
 }
Пример #11
0
 ///<summary>Patient identification.</summary>
 private void PID(Patient pat)
 {
     seg = new SegmentHL7(SegmentName.PID);
     seg.SetField(0, "PID");
     seg.SetField(2, pat.PatNum.ToString());
     seg.SetField(3, pat.PatNum.ToString());
     seg.SetField(5, pat.LName, pat.FName);
     if (pat.Birthdate.Year > 1880)           //7: dob optional
     {
         seg.SetField(7, pat.Birthdate.ToString("yyyyMMdd"));
     }
     seg.SetField(8, ConvertGender(pat.Gender));
     seg.SetField(10, ConvertRace(pat.Race));
     seg.SetField(11, pat.Address, pat.Address2, pat.City, pat.State, pat.Zip, "", "M");     //M is for mailing.
     seg.SetField(13, ConvertPhone(pat.HmPhone));
     seg.SetField(22, ConvertEthnicGroup(pat.Race));
     msg.Segments.Add(seg);
 }
Пример #12
0
 ///<summary>PDF data segment.</summary>
 private void ZX1(string pdfDataAsBase64, string pdfDescription)
 {
     seg = new SegmentHL7(SegmentNameHL7.ZX1);
     seg.SetField(0, "ZX1");
     seg.SetField(1, "6");
     seg.SetField(2, "PDF");
     seg.SetField(3, "PATHOLOGY^Pathology Report^L");
     seg.SetField(4, pdfDescription);
     seg.SetField(5, pdfDataAsBase64);
     msg.Segments.Add(seg);
 }
Пример #13
0
Файл: EcwDFT.cs Проект: mnisl/OD
		///<summary>Financial transaction segment.</summary>
		private void FT1(long aptNum,bool justPDF){
			if(justPDF){
				return;//FT1 segment is not necessary when sending only a PDF.
			}
			List<Procedure> procs=Procedures.GetProcsForSingle(aptNum,false);
			ProcedureCode procCode;
			for(int i=0;i<procs.Count;i++) {
				seg=new SegmentHL7(SegmentNameHL7.FT1);
				seg.SetField(0,"FT1");
				seg.SetField(1,(i+1).ToString());
				seg.SetField(4,procs[i].ProcDate.ToString("yyyyMMddHHmmss"));
				seg.SetField(5,procs[i].ProcDate.ToString("yyyyMMddHHmmss"));
				seg.SetField(6,"CG");
				seg.SetField(10,"1.0");
				seg.SetField(16,"");//location code and description???
				seg.SetField(19,procs[i].DiagnosticCode);
				Provider prov=Providers.GetProv(procs[i].ProvNum);
				seg.SetField(20,prov.EcwID,prov.LName,prov.FName,prov.MI);//performed by provider.
				seg.SetField(21,prov.EcwID,prov.LName,prov.FName,prov.MI);//ordering provider.
				seg.SetField(22,procs[i].ProcFee.ToString("F2"));
				procCode=ProcedureCodes.GetProcCode(procs[i].CodeNum);
				if(procCode.ProcCode.Length>5 && procCode.ProcCode.StartsWith("D")) {
					seg.SetField(25,procCode.ProcCode.Substring(0,5));//Remove suffix from all D codes.
				}
				else {
					seg.SetField(25,procCode.ProcCode);
				}
				if(procCode.TreatArea==TreatmentArea.ToothRange){
					seg.SetField(26,procs[i].ToothRange,"");
				}
				else if(procCode.TreatArea==TreatmentArea.Surf){//probably not necessary
					seg.SetField(26,Tooth.ToInternat(procs[i].ToothNum),Tooth.SurfTidyForClaims(procs[i].Surf,procs[i].ToothNum));
				}
				else if(procCode.TreatArea==TreatmentArea.Quad && ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.eClinicalWorks),"IsQuadAsToothNum")=="1") {
					seg.SetField(26,procs[i].Surf,"");
				}
				else{
					seg.SetField(26,Tooth.ToInternat(procs[i].ToothNum),procs[i].Surf);
				}
				msg.Segments.Add(seg);
			}
		}
Пример #14
0
		///<summary>Patient Identifier segment.  Required.  Guide page 137.</summary>
		private void PID() {
			_seg=new SegmentHL7(SegmentNameHL7.PID);
			_seg.SetField(0,"PID");
			_seg.SetField(1,"1");//PID-1 Set ID - PID.  Required if known.  Cardinality [0..1].  Must be "1" for the first occurrence.  Not sure why there would ever be more than one.
			//PID-2 Patient ID.  No longer used.
			//PID-3 Patient Identifier List.  Required.  Cardinality [1..*].  Type CX (see guide page 58 for type definition).
			_seg.SetField(3,
				_pat.PatNum.ToString(),//PID-3.1 ID Number.  Required (length 1..15).
				"",//PID-3.2 Check Digit.  Optional (length 1..1).
				"",//PID-3.3 Check Digit Scheme.  Required if PID-3.2 is specified.  Not required for our purposes.  Value set HL70061.
				"Open Dental",//PID-3.4 Assigning Authority.  Required.  Value set HL70363.
				"MR"//PID-3.5 Identifier Type Code.  Required (length 2..5).  Value set HL70203.  MR=medical record number.
				//PID-3.6 Assigning Facility.  Optional (length undefined).
				//PID-3.7 Effective Date.  Optional (length 4..8).
				//PID-3.8 Expiration Date.  Optional (length 4..8).
				//PID-3.9 Assigning Jurisdiction.  Optional (length undefined).
				//PID-3.10 Assigning Agency or Department.  Optional (length undefined).
			);
			if(_pat.SSN.Trim()!="") {
				_seg.RepeatField(3,
					_pat.SSN.Trim(),//PID-3.1 ID Number.  Required (length 1..15).
					"",//PID-3.2 Check Digit.  Optional (length 1..1).
					"",//PID-3.3 Check Digit Scheme.  Required if PID-3.2 is specified.  Not required for our purposes.  Value set HL70061.
					"Open Dental",//PID-3.4 Assigning Authority.  Required.  Value set HL70363.
					"SS"//PID-3.5 Identifier Type Code.  Required (length 2..5).  Value set HL70203.  SS=Social Security Number.
						//PID-3.6 Assigning Facility.  Optional (length undefined).
						//PID-3.7 Effective Date.  Optional (length 4..8).
						//PID-3.8 Expiration Date.  Optional (length 4..8).
						//PID-3.9 Assigning Jurisdiction.  Optional (length undefined).
						//PID-3.10 Assigning Agency or Department.  Optional (length undefined).
				);
			}
			//PID-4 Alternate Patient ID - 00106.  No longer used.
			WriteXPN(5,_pat.FName,_pat.LName,_pat.MiddleI,"L");//PID-5 Patient Name.  Required (length unspecified).  Cardinality [1..*].  Type XPN.  The first repetition must contain the legal name.
			EhrPatient ehrPatient=EhrPatients.Refresh(_pat.PatNum);
			WriteXPN(6,ehrPatient.MotherMaidenFname,ehrPatient.MotherMaidenLname,"","M");//PID-6 Mother's Maiden Name.  Required if known (length unspecified).  Cardinality [0..1].  Type XPN.
			//PID-7 Date/Time of Birth.  Required.  Cardinality [1..1].  We must specify "UNK" if unknown.
			if(_pat.Birthdate.Year<1880) {
				_seg.SetField(7,"UNK");
			}
			else {
				_seg.SetField(7,_pat.Birthdate.ToString("yyyyMMdd"));
			}
			WriteGender(8,_pat.Gender);//PID-8 Administrative Sex.  Required if known.  Cardinality [0..1].  Value set HL70001.
			//PID-9 Patient Alias.  No longer used.
			//PID-10 Race.  Required if known.  Cardinality [0..*].  Value set HL70005 (guide page 194).  Each race definition must be type CE.  Type CE is defined on guide page 53.
			List<PatientRace> listPatientRaces=PatientRaces.GetForPatient(_pat.PatNum);
			List<PatRace> listPatRacesFiltered=new List<PatRace>();
			bool isHispanicOrLatino=false;
			for(int i=0;i<listPatientRaces.Count;i++) {
				PatRace patRace=listPatientRaces[i].Race;
				if(patRace==PatRace.Hispanic) {
					isHispanicOrLatino=true;
				}
				else if(patRace==PatRace.NotHispanic) {
					//Nothing to do. Flag is set to false by default.
				}
				else if(patRace==PatRace.DeclinedToSpecifyRace) {
					listPatRacesFiltered.Clear();
					break;
				}
				else {
					listPatRacesFiltered.Add(patRace);
				}
			}
			for(int i=0;i<listPatRacesFiltered.Count;i++) {
				PatRace patRace=listPatRacesFiltered[i];
				string strRaceCode="";
				string strRaceName="";
				if(patRace==PatRace.AfricanAmerican) {
					strRaceCode="2054-5";
					strRaceName="Black or African American";
				}
				else if(patRace==PatRace.AmericanIndian) {
					strRaceCode="1002-5";
					strRaceName="American Indian or Alaska Native";
				}
				else if(patRace==PatRace.Asian) {
					strRaceCode="2028-9";
					strRaceName="Asian";
				}
				else if(patRace==PatRace.HawaiiOrPacIsland) {
					strRaceCode="2076-8";
					strRaceName="Native Hawaiian or Other Pacific Islander";
				}
				else if(patRace==PatRace.White) {
					strRaceCode="2106-3";
					strRaceName="White";
				}
				else {//Aboriginal, Other, Multiracial
					strRaceCode="2131-1";
					strRaceName="Other Race";
				}
				_seg.SetOrRepeatField(10,
					strRaceCode,//PID-10.1 Identifier.  Required (length 1..50).
					strRaceName,//PID-10.2  Text.  Required if known (length 1..999). Human readable text that is not further used.
					"HL70005"//PID-10.3 Name of Coding System.  Required (length 1..20).
					//PID-10.4 Alternate Identifier.  Required if known (length 1..50).
					//PID-10.5 Alternate Text.  Required if known (length 1..999).
					//PID-10.6 Name of Alternate Coding system.  Required if PID-10.4 is not blank.
				);
			}
			//PID-11 Patient Address.  Required if known (length unspecified).  Cardinality [0..*].  Type XAD (guide page 74).  First repetition must be the primary address.
			WriteXAD(11,_pat.Address,_pat.Address2,_pat.City,_pat.State,_pat.Zip);
			//PID-12 County Code.  No longer used.
			//PID-13 Phone Number - Home.  Required if known (length unspecified).  Cardinality [0..*].  Type XTN (guide page 84).  The first number must be the primary number (if email only, then blank phone followed by email).
			WriteXTN(13,"PRN","PH","F",_pat.HmPhone,"PRN","CP","",_pat.WirelessPhone,"NET","Internet","",_pat.Email);
			//PID-14 Phone Number - Business.  Optional.
			//PID-15 Primary Language.  Optional.
			//PID-16 Marital Status.  Optional.
			//PID-17 Religion.  Optional.
			//PID-18 Patient Account Number.  Optional.
			//PID-19 SSN Number - Patient.  No longer used.
			//PID-20 Driver's License Number - Patient.  No longer used.
			//PID-21 Mother's Identifier.  No longer used.
			//PID-22 Ethnic Group.  Required if known (length unspecified).  Cardinality [0..1].  Value set HL70189 (guide page 201).  Type CE.
			if(listPatRacesFiltered.Count>0) {//The user specified a race and ethnicity and did not select the decline to specify option.
				if(isHispanicOrLatino) {
					WriteCE(22,"2135-2","Hispanic or Latino","CDCREC");
				}
				else {//Not hispanic or latino.
					WriteCE(22,"2186-5","not Hispanic or Latino","CDCREC");
				}
			}
			//PID-23 Birth Place.  Optional.  Cardinaility [0..1].
			//PID-24 Multiple Birth Indicator.  Optional.  Cardinaility [0..1].
			//PID-25 Birth Order.  Required when PID-24 is set to "Y".  Cardinaility [0..1].
			//PID-26 Citizenship.  Optional.  Cardinaility [0..1].
			//PID-27 Veterans Military Status.  Optional.  Cardinaility [0..1].
			//PID-28 Nationality.  Optional.  Cardinaility [0..1].
			//PID-29 Patient Death Date and Time.  Required if PID-30 is set to "Y".  Cardinaility [0..1].  Date is required, time is not.
			//PID-30 Patient Death Indicator.  Required if known.  Cardinaility [0..1].  Value set HL70136.  Set this field to "Y" if the death date and time year is greater than 1880, otherwise do not set.
			//PID-31 Identity Unknown.  Optional.  Cardinaility [0..1].
			//PID-32 Identity Reliability Code.  Optional.  Cardinaility [0..1].
			//PID-33 Last Update Date/Time.  Optional.  Cardinaility [0..1].
			//PID-34 Last Update Facility.  Optional.  Cardinaility [0..1].
			//PID-35 Species Code.  Optional.  Cardinaility [0..1].
			//PID-36 Breed Code.  Optional.  Cardinaility [0..1].
			//PID-37 Strain.  Optional.  Cardinaility [0..1].
			//PID-38 Production Class Code.  Optional.  Cardinaility [0..1].
			//PID-39 Tribal Citizenship.  Optional.  Cardinaility [0..1].
			_msg.Segments.Add(_seg);
		}
Пример #15
0
		///<summary>Order Request segment.  Required.  Guide page 126.</summary>
		private void ORC(VaccinePat vaccine) {
			_seg=new SegmentHL7(SegmentNameHL7.ORC);
			_seg.SetField(0,"ORC");
			_seg.SetField(1,"RE");//ORC-1 Order Control.  Required (length 2).  Cardinality [1..1].  Value set HL70119.  The only allowed value is "RE".
			//ORC-2 Placer Order Number.  Required if known.  Cardinality [0..1].  Type EI (guid page 62).
			//ORC-3 Filler Order Number.  Required.  Cardinality [0..1].  Type EI (guid page 62).  "Shall be the unique ID of the sending system."  The city and state are used to record the region where the vaccine record was filled.
			WriteEI(3,vaccine.VaccinePatNum.ToString(),vaccine.FilledCity.Trim(),vaccine.FilledST.Trim());
			//ORC-4 Placer Group Number.  Optional.
			//ORC-5 Order Status.  Optional.
			//ORD-6 Response Flag.  Optional.
			//ORD-7 Quantity/Timing.  No longer used.
			//ORD-8 Parent.  Optional.
			//ORD-9 Date/Time of Transaction.  Optional.
			//ORD-10 Entered By.  Required if known.  Cardinality [0..1].  Type XCN.  This is the person that entered the immunization record into the system.
			Userod userod=Userods.GetUser(vaccine.UserNum);//Can be null if vaccine.UserNum=0 for older records before the vaccine.UserNum column existed.
			if(userod!=null) {
				if(userod.ProvNum!=0) {
					Provider provEnteredBy=Providers.GetProv(userod.ProvNum);
					WriteXCN(10,provEnteredBy.FName,provEnteredBy.LName,provEnteredBy.MI,vaccine.UserNum.ToString(),cityWhereEntered,stateWhereEntered,"D");
				}
				else if(userod.EmployeeNum!=0) {
					Employee employee=Employees.GetEmp(userod.EmployeeNum);
					WriteXCN(10,employee.FName,employee.LName,employee.MiddleI,vaccine.UserNum.ToString(),cityWhereEntered,stateWhereEntered,"D");
				}
			}
			//ORD-11 Verified By.  Optional.
			//ORD-12 Ordering Provider.  Required if known. Cardinality [0..1].  Type XCN.  This shall be the provider ordering the immunization.  It is expected to be empty if the immunization record is transcribed from a historical record.
			Provider provOrdering=Providers.GetProv(vaccine.ProvNumOrdering);//Can be null if vaccine.ProvNumOrdering is zero.
			if(provOrdering!=null) {
				WriteXCN(12,provOrdering.FName,provOrdering.LName,provOrdering.MI,provOrdering.ProvNum.ToString(),cityWhereEntered,stateWhereEntered,"L");
			}
			//ORD-13 Enterer's Location.  Optional.
			//ORD-14 Call Back Phone Number.  Optional.
			//ORD-15 Order Effective Date/Time.  Optional.
			//ORD-16 Order Control Code Reason.  Optional.
			//ORD-17 Entering Organization.  Optional.
			//ORD-18 Entering Device.  Optional.
			//ORD-19 Action By.  Optional.
			//ORD-20 Advanced Beneficiary Notice Code.  Optional.
			//ORD-21 Ordering Facility Name.  Optional.
			//ORD-22 Ordering Facility Address.  Optional.
			//ORD-23 Ordering Facility.  Optional.
			//ORD-24 Order Provider Address.  Optional.
			//ORD-25 Order Status Modifier.  Optional.
			//ORD-26 Advanced Beneficiary Notice Override Reason.  Optional.
			//ORD-27 Filler's Expected Availability Date/Time.  Optional.
			//ORD-28 Confidentiality Code.  Optional.
			//ORD-29 Order Type.  Optional.
			//ORD-30 Enterer Authorization Mode.  Optional.
			//ORD-31 Parent Universal Service Modifier.  Optional.
			_msg.Segments.Add(_seg);
		}
Пример #16
0
		///<summary>Next of Kin segment.  Required if known.  Guide page 111.</summary>
		private void NK1() {
			List<Guardian> listGuardians=Guardians.Refresh(_pat.PatNum);
			for(int i=0;i<listGuardians.Count;i++) {//One NK1 segment for each relationship.
				_seg=new SegmentHL7(SegmentNameHL7.NK1);
				_seg.SetField(0,"NK1");
				_seg.SetField(1,(i+1).ToString());//NK1-1 Set ID.  Required (length unspecified).  Cardinality [1..1].
				//NK-2 Name.  Required (length unspecified).  Type XPN (guide page 82).  Cardinarlity [1..1].
				Patient patNextOfKin=Patients.GetPat(listGuardians[i].PatNumGuardian);
				WriteXPN(2,patNextOfKin.FName,patNextOfKin.LName,patNextOfKin.MiddleI,"L");
				//NK1-3 Relationship.  Required.  Cardinality [1..1].  Value set HL70063 (guide page 196).  Type CE.
				GuardianRelationship relat=listGuardians[i].Relationship;
				string strRelatCode="";
				if(relat==GuardianRelationship.Brother) {
					strRelatCode="BRO";
				}
				else if(relat==GuardianRelationship.CareGiver) {
					strRelatCode="CGV";
				}
				else if(relat==GuardianRelationship.Child) {
					strRelatCode="CHD";//This relationship type is not documented in the guide, but it is defined as part of HL7 0063 in a more recent publication.  We added because it seemed like a basic relationship type.
				}
				else if(relat==GuardianRelationship.Father) {
					strRelatCode="FTH";
				}
				else if(relat==GuardianRelationship.FosterChild) {
					strRelatCode="FCH";
				}
				else if(relat==GuardianRelationship.Friend) {
					strRelatCode="FND";//This relationship type is not documented in the guide, but it is defined as part of HL7 0063 in a more recent publication.  We added because it seemed like a basic relationship type.
				}
				else if(relat==GuardianRelationship.Grandchild) {
					strRelatCode="GCH";//This relationship type is not documented in the guide, but it is defined as part of HL7 0063 in a more recent publication.  We added because it seemed like a basic relationship type.
				}
				else if(relat==GuardianRelationship.Grandfather) { //This status is from our older guardian implementation.
					strRelatCode="GRD";//Grandparent
				}
				else if(relat==GuardianRelationship.Grandmother) { //This status is from our older guardian implementation.
					strRelatCode="GRD";//Grandparent
				}
				else if(relat==GuardianRelationship.Grandparent) {
					strRelatCode="GRD";
				}
				else if(relat==GuardianRelationship.Guardian) {
					strRelatCode="GRD";
				}
				else if(relat==GuardianRelationship.LifePartner) {
					strRelatCode="DOM";//This relationship type is not documented in the guide, but it is defined as part of HL7 0063 in a more recent publication.  We added because it seemed like a basic relationship type.
				}
				else if(relat==GuardianRelationship.Mother) {
					strRelatCode="MTH";
				}
				else if(relat==GuardianRelationship.Other) {
					strRelatCode="OTH";
				}
				else if(relat==GuardianRelationship.Parent) {
					strRelatCode="PAR";
				}
				else if(relat==GuardianRelationship.Self) {
					strRelatCode="SEL";
				}
				else if(relat==GuardianRelationship.Sibling) {
					strRelatCode="SIB";
				}
				else if(relat==GuardianRelationship.Sister) {
					strRelatCode="SIS";
				}
				else if(relat==GuardianRelationship.Sitter) { //This status is from our older guardian implementation.
					strRelatCode="CGV";//Caregiver
				}
				else if(relat==GuardianRelationship.Spouse) {
					strRelatCode="SPO";
				}
				else if(relat==GuardianRelationship.Stepchild) {
					strRelatCode="SCH";
				}
				else if(relat==GuardianRelationship.Stepfather) { //This status is from our older guardian implementation.
					strRelatCode="PAR";//parent
				}
				else if(relat==GuardianRelationship.Stepmother) { //This status is from our older guardian implementation.
					strRelatCode="PAR";//parent
				}
				else {
					continue;//Skip the entire segment if the relationship is not known.  Should not happen.
				}
				WriteCE(3,strRelatCode,relat.ToString(),"HL70063");
				//NK-4 Address.  Required if known (length unspecified).  Cardinality [0..1].  Type XAD (guide page 74).  The first instance must be the primary address.
				WriteXAD(4,patNextOfKin.Address,patNextOfKin.Address2,patNextOfKin.City,patNextOfKin.State,patNextOfKin.Zip);
				//NK-5 Phone Number.  Required if known.  Cardinality [0..*].  Type XTN (guide page 84).  The first instance shall be the primary phone number.
				WriteXTN(5,"PRN","PH","F",patNextOfKin.HmPhone,"PRN","CP","",patNextOfKin.WirelessPhone);
				//NK-6 Business Phone Number.  Optional.  Type XTN (guide page 84).
				WriteXTN(6,"WPN","PH","",patNextOfKin.WkPhone);
				//NK-7 Contact Role.  Optional.
				//NK-8 Start Date.  Optional.
				//NK-9 End Date.  Optional.
				//NK-10 Next of Kin/Associated Parties Job Title.  Optional.
				//NK-11 Next of Kin/Associated Parties Job Code/Class.  Optional.
				//NK-12 Next of Kin/Associated Parties Employee Number.  Optional.
				//NK-13 Organization Name - NK1.  Optional.
				//NK-14 Marital Status.  Optional.
				//NK-15 Administrative Sex.  Optional.
				//NK-16 Date/Time of Birth.  Optional.
				//NK-17 Living Dependency.  Optional.
				//NK-18 Ambulatory Status.  Optional.
				//NK-19 Citizenship.  Optional.
				//NK-20 Primary Language.  Optional.
				//NK-21 Living Arrangement.  Optional.
				//NK-22 Publicity Code.  Optional.
				//NK-23 Protection Indicator.  Optional.
				//NK-24 Student Indicator.  Optional.
				//NK-25 Religion.  Optional.
				//NK-26 Mother's Maiden Name.  Optional.
				//NK-27 Nationality.  Optional.
				//NK-28 Ethnic Group.  Optional.
				//NK-29 Contact Reason.  Optional.
				//NK-30 Contact Person's Name.  Optional.
				//NK-31 Contact Person's Telephone Number.  Optional.
				//NK-32 Contact Person's Address.  Optional.
				//NK-33 Next of Kin/Associated Party's Identifiers.  Optional.
				//NK-34 Job Status.  Optional.
				//NK-35 Race.  Optional.
				//NK-36 Handicap.  Optional.
				//NK-37 Contact Person Social Security Number.  Optional.
				//NK-38 Next of Kin Birth Place.  Optional.
				//NK-39 VIP Indicator.  Optional.
				_msg.Segments.Add(_seg);
			}
		}
Пример #17
0
        ///<summary>Financial transaction segment.</summary>
        private void FT1(long aptNum, bool justPDF)
        {
            if (justPDF)
            {
                return;                //FT1 segment is not necessary when sending only a PDF.
            }
            List <Procedure> procs = Procedures.GetProcsForSingle(aptNum, false);
            ProcedureCode    procCode;

            for (int i = 0; i < procs.Count; i++)
            {
                seg = new SegmentHL7(SegmentNameHL7.FT1);
                seg.SetField(0, "FT1");
                seg.SetField(1, (i + 1).ToString());
                seg.SetField(4, procs[i].ProcDate.ToString("yyyyMMddHHmmss"));
                seg.SetField(5, procs[i].ProcDate.ToString("yyyyMMddHHmmss"));
                seg.SetField(6, "CG");
                seg.SetField(10, "1.0");
                seg.SetField(16, "");               //location code and description???
                seg.SetField(19, procs[i].DiagnosticCode);
                Provider prov = Providers.GetProv(procs[i].ProvNum);
                seg.SetField(20, prov.EcwID, prov.LName, prov.FName, prov.MI);            //performed by provider.
                seg.SetField(21, prov.EcwID, prov.LName, prov.FName, prov.MI);            //ordering provider.
                seg.SetField(22, procs[i].ProcFee.ToString("F2"));
                procCode = ProcedureCodes.GetProcCode(procs[i].CodeNum);
                if (procCode.ProcCode.Length > 5 && procCode.ProcCode.StartsWith("D"))
                {
                    seg.SetField(25, procCode.ProcCode.Substring(0, 5));                  //Remove suffix from all D codes.
                }
                else
                {
                    seg.SetField(25, procCode.ProcCode);
                }
                if (procCode.TreatArea == TreatmentArea.ToothRange)
                {
                    seg.SetField(26, procs[i].ToothRange, "");
                }
                else if (procCode.TreatArea == TreatmentArea.Surf)              //probably not necessary
                {
                    seg.SetField(26, Tooth.ToInternat(procs[i].ToothNum), Tooth.SurfTidyForClaims(procs[i].Surf, procs[i].ToothNum));
                }
                else
                {
                    seg.SetField(26, Tooth.ToInternat(procs[i].ToothNum), procs[i].Surf);
                }
                msg.Segments.Add(seg);
            }
        }
Пример #18
0
        /*From	http://www.dt7.com/cdc/sampmsgs.html  example 1:
        Vaccine Adverse Event Report (VAERS form) (unfortunately, does not seem adaptable to our situation)
        MSH|^~\&||GA0000||VAERS PROCESSOR|20010331605||ORU^RO1|20010422GA03|T|2.3.1|||AL|
        PID|||1234^^^^SR~1234-12^^^^LR~00725^^^^MR||Doe^John^Fitzgerald^JR^^^L||20001007|M||2106-3^White^HL70005|123 Peachtree St^APT 3B^Atlanta^GA^30210^^M^^GA067||(678) 555-1212^^PRN|
        NK1|1|Jones^Jane^Lee^^RN|VAB^Vaccine administered by (Name)^HL70063|
        NK1|2|Jones^Jane^Lee^^RN|FVP^Form completed by (Name)-Vaccine provider^HL70063|101 Main Street^^Atlanta^GA^38765^^O^^GA121||(404) 554-9097^^WPN|
        ORC|CN|||||||||||1234567^Welby^Marcus^J^Jr^Dr.^MD^L|||||||||Peachtree Clinic|101 Main Street^^Atlanta^GA^38765^^O^^GA121|(404) 554-9097^^WPN|101 Main Street^^Atlanta^GA^38765^^O^^GA121|
        OBR|1|||^CDC VAERS-1 (FDA) Report|||20010316|
        OBX|1|NM|21612-7^Reported Patient Age^LN||05|mo^month^ANSI|
        OBX|1|TS|30947-6^Date form completed^LN||20010316|
        OBX|2|FT|30948-4^Vaccination adverse events and treatment, if any^LN|1|fever of 106F, with vomiting, seizures, persistent crying lasting over 3 hours, loss of appetite|
        OBX|3|CE|30949-2^Vaccination adverse event outcome^LN|1|E^required emergency room/doctor visit^NIP005|
        OBX|4|CE|30949-2^Vaccination adverse event outcome^LN|1|H^required hospitalization^NIP005|
        OBX|5|NM|30950-0^Number of days hospitalized due to vaccination adverse event^LN|1|02|d^day^ANSI|
        OBX|6|CE|30951-8^Patient recovered^LN||Y^Yes^ HL70239|
        OBX|7|TS|30952-6^Date of vaccination^LN||20010216|
        OBX|8|TS|30953-4^Adverse event onset date and time^LN||200102180900|
        OBX|9|FT|30954-2^Relevant diagnostic tests/lab data^LN||Electrolytes, CBC, Blood culture|
        OBR|2|||30955-9^All vaccines given on date listed in #10^LN|
        OBX|1|CE30955-9&30956-7^Vaccine type^LN|1|08^HepB-Adolescent/pediatric^CVX|
        OBX|2|CE|30955-9&30957-5^Manufacturer^LN|1|MSD^Merck^MVX|
        OBX|3|ST|30955-9&30959-1^Lot number^LN|1|MRK12345|
        OBX|4|CE|30955-9&30958-3^ Route^LN|1|IM^Intramuscular ^HL70162|
        OBX|5|CE|30955-9&31034-2^Site^LN|1|LA^Left arm^ HL70163|
        OBX|6|NM|30955-9&30960-9^Number of previous doses^LN|1|01I
        OBX|7|CE|CE|30955-9&30956-7^Vaccine type^LN|2|50^DTaP-Hib^CVX|
        OBX|8|CE|30955-9&30957-5^ Manufacturer^LN|2|WAL^Wyeth_Ayerst^MVX|
        OBX|9|ST|30955-9&30959-1^Lot number^LN|2|W46932777|
        OBX|10|CE|30955-9&30958-3^ Route^LN|2|IM^Intramuscular^HL70162|

         */
        /*This is the example that we are using for incorporating lab results in our other test.
          It is simpler than the above examples.  We might want to use it instead.
        MSH|^~\&|KAM|DGI|Y|OU|20100920093000||ORU^R01^ORU_R01|20100920093000|P|2.3.1
        PID||405979410 |405979410^^^&2.16.840.1.113883.19.3.2.1&ISO^MR||Lewis^Frank ||19500101|M||2106-3^White^HL70005|622 Chestnut^^Springfield^Tennessee^37026^^M||^^^^^615^3826396|||||405979410 ||||N^Not Hispanic or Latino^HL70189
        OBR|1|OrderNum-1001|FillOrder-1001|24331-1^Lipid Panel^LN||20100920083000|20100920083000|20100920083000|||||Hemolyzed ||| ProviderIDNum-100^Crow^Tom^Black^III^Dr.||||Aloha Laboratories 575 Luau Street Honolulu Hawaii 96813 ||||CH|F|
        OBX|1|NM|14647-2^Total cholesterol^LN |134465|162|mg/dl |<200| N|||F|||20100920083000
        OBX|2|NM|14646-4^HDL cholesterol^LN|333123|43|mg/dl|>=40| N|||F|||20100920083000
        OBX|3|NM|2089-1^LDL cholesterol^LN|333123|84|mg/dl|<100| N|||F|||20100920083000
        OBX|4|NM|14927-8^Triglycerides^LN|333123|127|mg/dl|<150| N|||F|||20100920083000*/
        /*This is example #5 from the mu site.  Hepatitis C is a legitimate reportable syndrome which would be reported to public health
        MSH|^~\&|EHR Application^2.16.840.1.113883.3.72.7.1^HL7|EHR Facility^2.16.840.1.113883.3.72.7.2^HL7|PH Application^2.16.840.1.113883.3.72.7.3^HL7|PH Facility^2.16.840.1.113883.3.72.7.4^HL7|20110316102334||ORU^R01^ORU_R01|NIST-110316102333943|P|2.5.1|||||||||PHLabReport-Ack^^2.16.840.1.114222.4.10.3^ISO
        SFT|NIST Lab, Inc.|3.6.23|A-1 Lab System|6742873-12||20080303
        PID|||686774009^^^MPI&2.16.840.1.113883.19.3.2.1&ISO^MR||Takamura^Michael||19820815|M||2028-9^Asian^HL70005|3567 Maple Street^^Oakland^CA^94605^USA^M||^PRN^^^^510^6658876|||||||||N^Not Hispanic or Latino^HL70189
        OBR|1||7564832^Lab^2.16.840.1.113883.19.3.1.6^ISO|10676-5^Hepatitis C Virus RNA^LN^1198112^Hepatitis C Test^99USI|||201007281400||||||Nausea, vomiting, abdominal pain|||1234^Admit^Alan^^^^^^ABC Medical Center&2.16.840.1.113883.19.4.6&ISO||||||201007301500|||F||||||787.01^Nausea and vomiting^I9CDX~789.0^Abdominal pain^I9CDX
        OBX|1|NM|10676-5^Hepatitis C Virus RNA^LN|1|850000|iU/mL^international units per mililiter^UCUM|High Viral Load > or = 850000iU/mL|H|||F|||201007281400|||||200807301500||||Lab^L^^^^CLIA&2.16.840.1.113883.19.4.6&ISO^XX^^^1236|3434 Industrial Lane^^Ann Arbor^MI^48103^^B
        SPM||||122555007^Venous blood specimen^SCT^BLDV^Blood venous^HL70487^20080131^2.5.1
        */
        private void OBR(LabPanel panel, DateTime datetime)
        {
            seg=new SegmentHL7(SegmentName.OBR);
            seg.SetField(0,"OBR");
            seg.SetField(1,"1");
            seg.SetField(2,"OrderNum-1001");
            seg.SetField(3,"FillOrder-1001");
            seg.SetField(4,panel.ServiceId,panel.ServiceName,"LN");//eg 10676-5, Hepatitis C Virus RNA
            seg.SetField(6,datetime.ToString("yyyyMMddhhmmss"));
            seg.SetField(7,datetime.ToString("yyyyMMddhhmmss"));
            seg.SetField(8,datetime.ToString("yyyyMMddhhmmss"));
            seg.SetField(13,panel.SpecimenCondition);
            seg.SetField(15,panel.SpecimenSource);
            seg.SetField(20,panel.LabNameAddress);
            seg.SetField(24,"CH");
            seg.SetField(25,"F");
            msg.Segments.Add(seg);
        }
Пример #19
0
        ///<summary>Patient Identifier segment.  Required.  Guide page 40.</summary>
        private void PID()
        {
            _seg = new SegmentHL7(SegmentNameHL7.PID);
            _seg.SetField(0, "PID");
            _seg.SetField(1, "1");           //PID-1 Set ID - PID.  Optional.  Cardinality [0..1].  Must be "1" for the first occurrence.  Not sure why there would ever be more than one.
            //PID-2 Patient ID.  No longer used.
            //PID-3 Patient Identifier List.  Required (length up to 478).  Cardinality [1..*].  Type CX.
            _seg.SetField(3,
                          _pat.PatNum.ToString(), //PID-3.1 ID Number.  Required (length 1..15).
                          "",                     //PID-3.2 Check Digit.  Optional (length 1..1).
                          "",                     //PID-3.3 Check Digit Scheme.  No longer used.
                          "Open Dental",          //PID-3.4 Assigning Authority.  Required (1..227).  Value set HL70363.
                          "MR"                    //PID-3.5 Identifier Type Code.  Required (length 2..5).  Value set HL70203.  MR=medical record number.
                                                  //PID-3.6 Assigning Facility.  Optional (length 1..227).
                                                  //PID-3.7 Effective Date.  No longer used.
                                                  //PID-3.8 Expiration Date.  No longer used.
                                                  //PID-3.9 Assigning Jurisdiction.  No longer used.
                                                  //PID-3.10 Assigning Facility.  No longer used.
                          );
            if (_pat.SSN.Trim() != "")
            {
                _seg.RepeatField(3,
                                 _pat.SSN.Trim(), //PID-3.1 ID Number.  Required (length 1..15).
                                 "",              //PID-3.2 Check Digit.  Optional (length 1..1).
                                 "",              //PID-3.3 Check Digit Scheme.  No longer used.
                                 "Open Dental",   //PID-3.4 Assigning Authority.  Required (length 1..227).  Value set HL70363.
                                 "SS"             //PID-3.5 Identifier Type Code.  Required (length 2..5).  Value set HL70203.  SS=Social Security Number.
                                                  //PID-3.6 Assigning Facility.  Optional (length 1..227).
                                                  //PID-3.7 Effective Date.  No longer used.
                                                  //PID-3.8 Expiration Date.  No longer used.
                                                  //PID-3.9 Assigning Jurisdiction.  No longer used.
                                                  //PID-3.10 Assigning Facility.  No longer used.
                                 );
            }
            //PID-4 Alternate Patient ID.  No longer used.
            //PID-5 Patient Name.  Required (length up to 294).  Cardinality [1..*].  Type XPN.  The first repetition must contain the legal name.
            WriteXPN(5, _pat.FName, _pat.LName, _pat.MiddleI, "L");
            //PID-6 Mother's Maiden Name.  No longer used.
            //PID-7 Date/Time of Birth.  Optional.  Cardinality [0..1].
            if (_pat.Birthdate.Year > 1880)
            {
                _seg.SetField(7, _pat.Birthdate.ToString("yyyyMMdd"));
            }
            WriteGender(8, _pat.Gender);           //PID-8 Administrative Sex.  Required if known.  Cardinality [0..1].  Value set HL70001.
            //PID-9 Patient Alias.  No longer used.
            //PID-10 Race.  Required if known.  Cardinality [0..*].  Value set HL70005.  Each race definition must be type CE.
            List <PatientRace> listPatientRaces     = PatientRaces.GetForPatient(_pat.PatNum);
            List <PatientRace> listPatRacesFiltered = new List <PatientRace>();
            bool isHispanicOrLatino = false;

            for (int i = 0; i < listPatientRaces.Count; i++)
            {
                if (listPatientRaces[i].IsEthnicity)
                {
                    if (listPatientRaces[i].CdcrecCode == "2186-5")                   //Not hispanic
                    //Nothing to do. Flag is set to false by default.
                    {
                    }
                    else if (listPatientRaces[i].CdcrecCode != PatientRace.DECLINE_SPECIFY_ETHNICITY_CODE)
                    {
                        isHispanicOrLatino = true;                      //All other ethnicities are Hispanic
                    }
                }
                else
                {
                    if (listPatientRaces[i].CdcrecCode == PatientRace.DECLINE_SPECIFY_RACE_CODE)
                    {
                        listPatRacesFiltered.Clear();
                        break;
                    }
                    listPatRacesFiltered.Add(listPatientRaces[i]);
                }
            }
            for (int i = 0; i < listPatRacesFiltered.Count; i++)
            {
                string strRaceCode = listPatRacesFiltered[i].CdcrecCode;
                string strRaceName = listPatRacesFiltered[i].Description;
                _seg.SetOrRepeatField(10,
                                      strRaceCode, //PID-10.1 Identifier.  Required (length 1..50).
                                      strRaceName, //PID-10.2  Text.  Required if known (length 1..999). Human readable text that is not further used.
                                      "CDCREC"     //PID-10.3 Name of Coding System.  Required (length 1..20).
                                                   //PID-10.4 Alternate Identifier.  Required if known (length 1..50).
                                                   //PID-10.5 Alternate Text.  Required if known (length 1..999).
                                                   //PID-10.6 Name of Alternate Coding system.  Required if PID-10.4 is not blank.
                                      );
            }
            //PID-11 Patient Address.  Required if known (length up to 513).  Cardinality [0..*].  Type XAD.
            WriteXAD(11, _pat.Address, _pat.Address2, _pat.City, _pat.State, _pat.Zip);
            //PID-12 County Code.  No longer used.
            //PID-13 Phone Number - Home.  No longer used.
            //PID-14 Phone Number - Business.  No longer used.
            //PID-15 Primary Language.  No longer used.
            //PID-16 Marital Status.  No longer used.
            //PID-17 Religion.  No longer used.
            //PID-18 Patient Account Number.  Optional.  However, we already sent this above.  Why do they have another field for this data?
            //PID-19 SSN Number - Patient.  No longer used.  We send SSN in PID-3.
            //PID-20 Driver's License Number - Patient.  No longer used.
            //PID-21 Mother's Identifier.  No longer used.
            //PID-22 Ethnic Group.  Required if known (length up to 478).  Cardinality [0..1].  Value set HL70189 (guide page 201).  Type CE.
            if (listPatRacesFiltered.Count > 0)           //The user specified a race and ethnicity and did not select the decline to specify option.
            {
                if (isHispanicOrLatino)
                {
                    WriteCE(22, "2135-2", "Hispanic or Latino", "CDCREC");
                }
                else                  //Not hispanic or latino.
                {
                    WriteCE(22, "2186-5", "not Hispanic or Latino", "CDCREC");
                }
            }
            //PID-23 Birth Place.  No longer used.
            //PID-24 Multiple Birth Indicator.  No longer used.
            //PID-25 Birth Order.  No longer used.
            //PID-26 Citizenship.  No longer used.
            //PID-27 Veterans Military Status.  No longer used.
            //PID-28 Nationality.  No longer used.
            //PID-29 Patient Death Date and Time.  Required if PID-30 is set to "Y" (length 12..26).  Cardinaility [0..1].
            if (_pat.DateTimeDeceased.Year > 1880)
            {
                _seg.SetField(29, _pat.DateTimeDeceased.ToString("yyyyMMddhhmmss"));
            }
            //PID-30 Patient Death Indicator.  Required if known.  Cardinaility [0..1].  Value set HL70136.
            if (_pat.DateTimeDeceased.Year > 1880)
            {
                _seg.SetField(30, "Y");
            }
            //PID-31 Identity Unknown.  No longer used.
            //PID-32 Identity Reliability Code.  No longer used.
            //PID-33 Last Update Date/Time.  Optional.  Cardinaility [0..1].
            //PID-34 Last Update Facility.  Optional.  Cardinaility [0..1].
            //PID-35 Species Code.  No longer used.
            //PID-36 Breed Code.  No longer used.
            //PID-37 Strain.  No longer used.
            //PID-38 Production Class Code.  No longer used.
            //PID-39 Tribal Citizenship.  No longer used.
            _msg.Segments.Add(_seg);
        }
Пример #20
0
		///<summary>Patient Identifier segment.  Required.  Guide page 40.</summary>
		private void PID() {
			_seg=new SegmentHL7(SegmentNameHL7.PID);
			_seg.SetField(0,"PID");
			_seg.SetField(1,"1");//PID-1 Set ID - PID.  Optional.  Cardinality [0..1].  Must be "1" for the first occurrence.  Not sure why there would ever be more than one.
			//PID-2 Patient ID.  No longer used.
			//PID-3 Patient Identifier List.  Required (length up to 478).  Cardinality [1..*].  Type CX.
			_seg.SetField(3,
				_pat.PatNum.ToString(),//PID-3.1 ID Number.  Required (length 1..15).
				"",//PID-3.2 Check Digit.  Optional (length 1..1).
				"",//PID-3.3 Check Digit Scheme.  No longer used.
				"Open Dental",//PID-3.4 Assigning Authority.  Required (1..227).  Value set HL70363.
				"MR"//PID-3.5 Identifier Type Code.  Required (length 2..5).  Value set HL70203.  MR=medical record number.
				//PID-3.6 Assigning Facility.  Optional (length 1..227).
				//PID-3.7 Effective Date.  No longer used.
				//PID-3.8 Expiration Date.  No longer used.
				//PID-3.9 Assigning Jurisdiction.  No longer used.
				//PID-3.10 Assigning Facility.  No longer used.
			);
			if(_pat.SSN.Trim()!="") {
				_seg.RepeatField(3,
					_pat.SSN.Trim(),//PID-3.1 ID Number.  Required (length 1..15).
					"",//PID-3.2 Check Digit.  Optional (length 1..1).
					"",//PID-3.3 Check Digit Scheme.  No longer used.
					"Open Dental",//PID-3.4 Assigning Authority.  Required (length 1..227).  Value set HL70363.
					"SS"//PID-3.5 Identifier Type Code.  Required (length 2..5).  Value set HL70203.  SS=Social Security Number.
					//PID-3.6 Assigning Facility.  Optional (length 1..227).
					//PID-3.7 Effective Date.  No longer used.
					//PID-3.8 Expiration Date.  No longer used.
					//PID-3.9 Assigning Jurisdiction.  No longer used.
					//PID-3.10 Assigning Facility.  No longer used.
				);
			}
			//PID-4 Alternate Patient ID.  No longer used.
			//PID-5 Patient Name.  Required (length up to 294).  Cardinality [1..*].  Type XPN.  The first repetition must contain the legal name.
			WriteXPN(5,_pat.FName,_pat.LName,_pat.MiddleI,"L");
			//PID-6 Mother's Maiden Name.  No longer used.
			//PID-7 Date/Time of Birth.  Optional.  Cardinality [0..1].
			if(_pat.Birthdate.Year>1880) {
				_seg.SetField(7,_pat.Birthdate.ToString("yyyyMMdd"));
			}
			WriteGender(8,_pat.Gender);//PID-8 Administrative Sex.  Required if known.  Cardinality [0..1].  Value set HL70001.
			//PID-9 Patient Alias.  No longer used.
			//PID-10 Race.  Required if known.  Cardinality [0..*].  Value set HL70005.  Each race definition must be type CE.
			List<PatientRace> listPatientRaces=PatientRaces.GetForPatient(_pat.PatNum);
			List<PatRace> listPatRacesFiltered=new List<PatRace>();
			bool isHispanicOrLatino=false;
			for(int i=0;i<listPatientRaces.Count;i++) {
				PatRace patRace=listPatientRaces[i].Race;
				if(patRace==PatRace.Hispanic) {
					isHispanicOrLatino=true;
				}
				else if(patRace==PatRace.NotHispanic) {
					//Nothing to do. Flag is set to false by default.
				}
				else if(patRace==PatRace.DeclinedToSpecifyRace) {
					listPatRacesFiltered.Clear();
					break;
				}
				else {
					listPatRacesFiltered.Add(patRace);
				}
			}
			for(int i=0;i<listPatRacesFiltered.Count;i++) {
				PatRace patRace=listPatRacesFiltered[i];
				string strRaceCode="";
				string strRaceName="";
				if(patRace==PatRace.AfricanAmerican) {
					strRaceCode="2054-5";
					strRaceName="Black or African American";
				}
				else if(patRace==PatRace.AmericanIndian) {
					strRaceCode="1002-5";
					strRaceName="American Indian or Alaska Native";
				}
				else if(patRace==PatRace.Asian) {
					strRaceCode="2028-9";
					strRaceName="Asian";
				}
				else if(patRace==PatRace.HawaiiOrPacIsland) {
					strRaceCode="2076-8";
					strRaceName="Native Hawaiian or Other Pacific Islander";
				}
				else if(patRace==PatRace.White) {
					strRaceCode="2106-3";
					strRaceName="White";
				}
				else {//Aboriginal, Other, Multiracial
					strRaceCode="2131-1";
					strRaceName="Other Race";
				}
				_seg.SetOrRepeatField(10,
					strRaceCode,//PID-10.1 Identifier.  Required (length 1..50).
					strRaceName,//PID-10.2  Text.  Required if known (length 1..999). Human readable text that is not further used.
					"CDCREC"//PID-10.3 Name of Coding System.  Required (length 1..20).
					//PID-10.4 Alternate Identifier.  Required if known (length 1..50).
					//PID-10.5 Alternate Text.  Required if known (length 1..999).
					//PID-10.6 Name of Alternate Coding system.  Required if PID-10.4 is not blank.
				);
			}
			//PID-11 Patient Address.  Required if known (length up to 513).  Cardinality [0..*].  Type XAD.
			WriteXAD(11,_pat.Address,_pat.Address2,_pat.City,_pat.State,_pat.Zip);
			//PID-12 County Code.  No longer used.
			//PID-13 Phone Number - Home.  No longer used.
			//PID-14 Phone Number - Business.  No longer used.
			//PID-15 Primary Language.  No longer used.
			//PID-16 Marital Status.  No longer used.
			//PID-17 Religion.  No longer used.
			//PID-18 Patient Account Number.  Optional.  However, we already sent this above.  Why do they have another field for this data?
			//PID-19 SSN Number - Patient.  No longer used.  We send SSN in PID-3.
			//PID-20 Driver's License Number - Patient.  No longer used.
			//PID-21 Mother's Identifier.  No longer used.
			//PID-22 Ethnic Group.  Required if known (length up to 478).  Cardinality [0..1].  Value set HL70189 (guide page 201).  Type CE.
			if(listPatRacesFiltered.Count>0) {//The user specified a race and ethnicity and did not select the decline to specify option.
				if(isHispanicOrLatino) {
					WriteCE(22,"2135-2","Hispanic or Latino","CDCREC");
				}
				else {//Not hispanic or latino.
					WriteCE(22,"2186-5","not Hispanic or Latino","CDCREC");
				}
			}
			//PID-23 Birth Place.  No longer used.
			//PID-24 Multiple Birth Indicator.  No longer used.
			//PID-25 Birth Order.  No longer used.
			//PID-26 Citizenship.  No longer used.
			//PID-27 Veterans Military Status.  No longer used.
			//PID-28 Nationality.  No longer used.
			//PID-29 Patient Death Date and Time.  Required if PID-30 is set to "Y" (length 12..26).  Cardinaility [0..1].
			if(_pat.DateTimeDeceased.Year>1880) {
				_seg.SetField(29,_pat.DateTimeDeceased.ToString("yyyyMMddhhmmss"));
			}
			//PID-30 Patient Death Indicator.  Required if known.  Cardinaility [0..1].  Value set HL70136.
			if(_pat.DateTimeDeceased.Year>1880) {
				_seg.SetField(30,"Y");
			}
			//PID-31 Identity Unknown.  No longer used.
			//PID-32 Identity Reliability Code.  No longer used.
			//PID-33 Last Update Date/Time.  Optional.  Cardinaility [0..1].
			//PID-34 Last Update Facility.  Optional.  Cardinaility [0..1].
			//PID-35 Species Code.  No longer used.
			//PID-36 Breed Code.  No longer used.
			//PID-37 Strain.  No longer used.
			//PID-38 Production Class Code.  No longer used.
			//PID-39 Tribal Citizenship.  No longer used.
			_msg.Segments.Add(_seg);
		}
Пример #21
0
		///<summary>Observation/result segment.  Used to transmit observations related to the patient and visit.  Guide page 64.</summary>
		private void OBX() {
			List<EhrAptObs> listObservations=EhrAptObses.Refresh(_appt.AptNum);
			for(int i=0;i<listObservations.Count;i++) {
				EhrAptObs obs=listObservations[i];
				_seg=new SegmentHL7(SegmentNameHL7.OBX);
				_seg.SetField(0,"OBX");
				_seg.SetField(1,(i+1).ToString());//OBX-1 Set ID - OBX.  Required (length 1..4).  Must start at 1 and increment.
				//OBX-2 Value Type.  Required (length 1..3).  Cardinality [1..1].  Identifies the structure of data in observation value OBX-5.  Values allowed: TS=Time Stamp (Date and/or Time),TX=Text,NM=Numeric,CWE=Coded with exceptions,XAD=Address.
				if(obs.ValType==EhrAptObsType.Coded) {
					_seg.SetField(2,"CWE");
				}
				else if(obs.ValType==EhrAptObsType.DateAndTime) {
					_seg.SetField(2,"TS");
				}
				else if(obs.ValType==EhrAptObsType.Numeric) {
					_seg.SetField(2,"NM");
				}
				else {//obs.ValType==EhrAptObsType.Text
					_seg.SetField(2,"TX");
				}
				//OBX-3 Observation Identifier.  Required (length up to 478).  Cardinality [1..1].  Value set is HL7 table named "Observation Identifier".  Type CE.  We use LOINC codes because the testing tool used LOINC codes and so do vaccines.
				string obsIdCode="";
				string obsIdCodeDescript="";
				string obsIdCodeSystem="LN";
				if(obs.IdentifyingCode==EhrAptObsIdentifier.BodyTemp) {
					obsIdCode="11289-6";
					obsIdCodeDescript="Body temperature:Temp:Enctrfrst:Patient:Qn:";
				}
				else if(obs.IdentifyingCode==EhrAptObsIdentifier.CheifComplaint) {
					obsIdCode="8661-1";
					obsIdCodeDescript="Chief complaint:Find:Pt:Patient:Nom:Reported";
				}
				else if(obs.IdentifyingCode==EhrAptObsIdentifier.DateIllnessOrInjury) {
					obsIdCode="11368-8";
					obsIdCodeDescript="Illness or injury onset date and time:TmStp:Pt:Patient:Qn:";
				}
				else if(obs.IdentifyingCode==EhrAptObsIdentifier.OxygenSaturation) {
					obsIdCode="59408-5";
					obsIdCodeDescript="Oxygen saturation:MFr:Pt:BldA:Qn:Pulse oximetry";
				}
				else if(obs.IdentifyingCode==EhrAptObsIdentifier.PatientAge) {
					obsIdCode="21612-7";
					obsIdCodeDescript="Age Time Patient Reported";
				}
				else if(obs.IdentifyingCode==EhrAptObsIdentifier.PrelimDiag) {
					obsIdCode="44833-2";
					obsIdCodeDescript="Diagnosis.preliminary:Imp:Pt:Patient:Nom:";
				}
				else if(obs.IdentifyingCode==EhrAptObsIdentifier.TreatFacilityID) {
					obsIdCode="SS001";
					obsIdCodeDescript="Treating Facility Identifier";
					obsIdCodeSystem="PHINQUESTION";
				}
				else if(obs.IdentifyingCode==EhrAptObsIdentifier.TreatFacilityLocation) {
					obsIdCode="SS002";
					obsIdCodeDescript="Treating Facility Location";
					obsIdCodeSystem="PHINQUESTION";
				}
				else if(obs.IdentifyingCode==EhrAptObsIdentifier.TriageNote) {
					obsIdCode="54094-8";
					obsIdCodeDescript="Triage note:Find:Pt:Emergency department:Doc:";
				}
				else if(obs.IdentifyingCode==EhrAptObsIdentifier.VisitType) {
					obsIdCode="SS003";
					obsIdCodeDescript="Facility / Visit Type";
					obsIdCodeSystem="PHINQUESTION";
				}
				WriteCE(3,obsIdCode,obsIdCodeDescript,obsIdCodeSystem);
				//OBX-4 Observation Sub-ID.  No longer used.
				//OBX-5 Observation Value.  Required if known (length 1..99999).  Value must match type in OBX-2.
				if(obs.ValType==EhrAptObsType.Address) {
					WriteXAD(5,_sendingFacilityAddress1,_sendingFacilityAddress2,_sendingFacilityCity,_sendingFacilityState,_sendingFacilityZip);
				}
				else if(obs.ValType==EhrAptObsType.Coded) {
					string codeDescript="";
					string codeSystemAbbrev="";
					if(obs.ValCodeSystem.Trim().ToUpper()=="LOINC") {
						Loinc loincVal=Loincs.GetByCode(obs.ValReported);
						codeDescript=loincVal.NameShort;
						codeSystemAbbrev="LN";
					}
					else if(obs.ValCodeSystem.Trim().ToUpper()=="SNOMEDCT") {
						Snomed snomedVal=Snomeds.GetByCode(obs.ValReported);
						codeDescript=snomedVal.Description;
						codeSystemAbbrev="SCT";
					}
					else if(obs.ValCodeSystem.Trim().ToUpper()=="ICD9") {
						ICD9 icd9Val=ICD9s.GetByCode(obs.ValReported);
						codeDescript=icd9Val.Description;
						codeSystemAbbrev="I9";
					}
					else if(obs.ValCodeSystem.Trim().ToUpper()=="ICD10") {
						Icd10 icd10Val=Icd10s.GetByCode(obs.ValReported);
						codeDescript=icd10Val.Description;
						codeSystemAbbrev="I10";
					}
					WriteCE(5,obs.ValReported.Trim(),codeDescript,codeSystemAbbrev);
				}
				else if(obs.ValType==EhrAptObsType.DateAndTime) {
					DateTime dateVal=DateTime.Parse(obs.ValReported.Trim());
					string strDateOut=dateVal.ToString("yyyyMMdd");
					//The testing tool threw errors when there were trailing zeros, even though technically valid.
					if(dateVal.Second>0) {
						strDateOut+=dateVal.ToString("HHmmss");
					}
					else if(dateVal.Minute>0) {
						strDateOut+=dateVal.ToString("HHmm");
					}
					else if(dateVal.Hour>0) {
						strDateOut+=dateVal.ToString("HH");
					}
					_seg.SetField(5,strDateOut);
				}
				else if(obs.ValType==EhrAptObsType.Numeric) {
					_seg.SetField(5,obs.ValReported.Trim());
				}
				else { //obs.ValType==EhrAptObsType.Text
					_seg.SetField(5,obs.ValReported);
				}
				//OBX-6 Units.  Required if OBX-2 is NM=Numeric.  Cardinality [0..1].  Type CE.  The guide suggests value sets: Pulse Oximetry Unit, Temperature Unit, or Age Unit.  However, the testing tool used UCUM, so we will use UCUM.
				if(obs.ValType==EhrAptObsType.Numeric) {
					if(String.IsNullOrEmpty(obs.UcumCode)) { //If units are required but known, we must send a null flavor.
						WriteCE(6,"UNK","","NULLFL");
					}
					else {
						Ucum ucum=Ucums.GetByCode(obs.UcumCode);
						WriteCE(6,ucum.UcumCode,ucum.Description,"UCUM");
					}
				}
				//OBX-7 References Range.  No longer used.
				//OBX-8 Abnormal Flags.  No longer used.
				//OBX-9 Probability.  No longer used.
				//OBX-10 Nature of Abnormal Test.  No longer used.
				_seg.SetField(11,"F");//OBX-11 Observation Result Status.  Required (length 1..1).  Expected value is "F".
				//OBX-12 Effective Date of Reference Range.  No longer used.
				//OBX-13 User Defined Access Checks.  No longer used.
				//OBX-14 Date/Time of the Observation.  Optional.
				//OBX-15 Producer's ID.  No longer used.
				//OBX-16 Responsible Observer.  No longer used.
				//OBX-17 Observation Method.  No longer used.
				//OBX-18 Equipment Instance Identifier.  No longer used.
				//OBX-19 Date/Time of the Analysis.  No longer used.
				_msg.Segments.Add(_seg);
			}
		}
Пример #22
0
        ///<summary>Returns null if there is no DFT defined for the enabled HL7Def.</summary>
        public static MessageHL7 GenerateDFT(List <Procedure> procList, EventTypeHL7 eventType, Patient pat, Patient guar, long aptNum, string pdfDescription, string pdfDataString)   //add event (A04 etc) parameters later if needed
        //In \\SERVERFILES\storage\OPEN DENTAL\Programmers Documents\Standards (X12, ADA, etc)\HL7\Version2.6\V26_CH02_Control_M4_JAN2007.doc
        //On page 28, there is a Message Construction Pseudocode as well as a flowchart which might help.
        {
            Provider    prov       = Providers.GetProv(Patients.GetProvNum(pat));
            Appointment apt        = Appointments.GetOneApt(aptNum);
            MessageHL7  messageHL7 = new MessageHL7(MessageTypeHL7.DFT);
            HL7Def      hl7Def     = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find a DFT message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.DFT)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    //continue;
                    break;
                }
            }
            if (hl7DefMessage == null)           //DFT message type is not defined so do nothing and return
            {
                return(null);
            }
            for (int s = 0; s < hl7DefMessage.hl7DefSegments.Count; s++)
            {
                int countRepeat = 1;
                if (hl7DefMessage.hl7DefSegments[s].SegmentName == SegmentNameHL7.FT1)
                {
                    countRepeat = procList.Count;
                }
                //for example, countRepeat can be zero in the case where we are only sending a PDF of the TP to eCW, and no procs.
                for (int repeat = 0; repeat < countRepeat; repeat++)           //FT1 is optional and can repeat so add as many FT1's as procs in procList
                //if(hl7DefMessage.hl7DefSegments[s].SegmentName==SegmentNameHL7.FT1) {
                {
                    if (hl7DefMessage.hl7DefSegments[s].SegmentName == SegmentNameHL7.FT1 && procList.Count > repeat)
                    {
                        prov = Providers.GetProv(procList[repeat].ProvNum);
                    }
                    SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[s].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[s].SegmentName.ToString());
                    for (int f = 0; f < hl7DefMessage.hl7DefSegments[s].hl7DefFields.Count; f++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos, hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FixedText);
                        }
                        else
                        {
                            //seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos,
                            //FieldConstructor.GenerateDFT(hl7Def,fieldName,pat,prov,procList[repeat],guar,apt,repeat+1,eventType,pdfDescription,pdfDataString));
                            Procedure proc = null;
                            if (procList.Count > repeat)                           //procList could be an empty list
                            {
                                proc = procList[repeat];
                            }
                            seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos,
                                         FieldConstructor.GenerateDFT(hl7Def, fieldName, pat, prov, proc, guar, apt, repeat + 1, eventType, pdfDescription, pdfDataString));
                        }
                    }
                    messageHL7.Segments.Add(seg);
                }
            }
            return(messageHL7);
        }
Пример #23
0
		///<summary>Returns null if no HL7 def is enabled or no SRR is defined in the enabled def.  An SRR - Schedule Request Response message is sent when an SRM - Schedule Request Message is received.  The SRM is acknowledged just like any inbound message, but the SRR notifies the placer application that the requested modification took place.  Currently the only appointment modifications allowed are updating the appt note, setting the dentist and hygienist, updating the confirmation status, and changing the ClinicNum.  Setting the appointment status to Broken is also supported.</summary>
		public static MessageHL7 GenerateSRR(Patient pat,Appointment apt,EventTypeHL7 eventType,string controlId,bool isAck,string ackEvent) {
			HL7Def hl7Def=HL7Defs.GetOneDeepEnabled();
			if(hl7Def==null) {
				return null;
			}
			//find an outbound SRR message in the def
			HL7DefMessage hl7DefMessage=null;
			for(int i=0;i<hl7Def.hl7DefMessages.Count;i++) {
				if(hl7Def.hl7DefMessages[i].MessageType==MessageTypeHL7.SRR && hl7Def.hl7DefMessages[i].InOrOut==InOutHL7.Outgoing) {
					hl7DefMessage=hl7Def.hl7DefMessages[i];
					break;
				}
			}
			if(hl7DefMessage==null) {//SRR message type is not defined so do nothing and return
				return null;
			}
			if(PrefC.GetBool(PrefName.ShowFeaturePatientClone)) {
				Patient patClone;
				Patient patNonClone;
				List<Patient> listAmbiguousMatches;
				Patients.GetCloneAndNonClone(pat,out patClone,out patNonClone,out listAmbiguousMatches);
				if(patNonClone!=null) {
					pat=patNonClone;
				}
			}
			MessageHL7 msgHl7=new MessageHL7(MessageTypeHL7.SRR);
			Provider provPri=Providers.GetProv(apt.ProvNum);
			//go through each segment in the def
			for(int i=0;i<hl7DefMessage.hl7DefSegments.Count;i++) {
				List<Provider> listProvs=new List<Provider>();
				listProvs.Add(provPri);
				if(hl7DefMessage.hl7DefSegments[i].SegmentName==SegmentNameHL7.AIP && apt.ProvHyg>0) {
					listProvs.Add(Providers.GetProv(apt.ProvHyg));
				}
				for(int j=0;j<listProvs.Count;j++) {//AIP will be repeated if there is a dentist and a hygienist on the appt
					Provider prov=listProvs[j];
					SegmentHL7 seg=new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
					seg.SetField(0,hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
					for(int k=0;k<hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count;k++) {
						string fieldName=hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FieldName;
						if(fieldName=="") {//If fixed text instead of field name just add text to segment
							seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos,hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FixedText);
						}
						else {
							string fieldValue="";
							if(hl7DefMessage.hl7DefSegments[i].SegmentName==SegmentNameHL7.MSA) {
								fieldValue=FieldConstructor.GenerateFieldACK(hl7Def,fieldName,controlId,isAck,ackEvent);
							}
							else {
								fieldValue=FieldConstructor.GenerateFieldSRR(hl7Def,fieldName,pat,prov,apt,j+1,eventType,seg.Name);
							}
							seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos,fieldValue);
						}
					}
					msgHl7.Segments.Add(seg);
				}
			}
			return msgHl7;
		}
Пример #24
0
 //OBR|1|||30955-9^Vaccine Given^LN|
 //OBX|1|CE30955-9&30956-7^Vaccine type^LN|1|08^HepB-Adolescent/pediatric^CVX|
 /// <summary>idx passed in will be zero-based. Will be converted to 1-based.</summary>
 private void OBX(LabResult labresult,int idx)
 {
     seg=new SegmentHL7(SegmentName.OBX);
     seg.SetField(0,"OBX");
     seg.SetField(1,(idx+1).ToString());
     seg.SetField(2,"NM");//ValueType. NM=numeric, referring to the value that will follow in OBX-5
     seg.SetField(3,labresult.TestID,labresult.TestName,"LN");//TestPerformed  ID^text^codingSystem.  eg. 10676-5^Hepatitis C Virus RNA^LN
     seg.SetField(4,"1");//?
     seg.SetField(5,labresult.ObsValue);//Value. Type based on OBX-2.  eg. 850000.
     seg.SetField(6,labresult.ObsUnits);//Units. Example iU/mL^international units per mililiter
     seg.SetField(7,labresult.ObsRange);//Range. Example High Viral Load >= 850000iU/mL
     seg.SetField(8,"N");//?
     seg.SetField(11,"F");//OBX-11 is required.  F means final.
     seg.SetField(14,labresult.DateTimeTest.ToString("yyyyMMddhhmmss"));//OBX-14 datetime
     msg.Segments.Add(seg);
 }
Пример #25
0
		///<summary>Pharmacy/Treatment Route segment.  Required if known.  Guide page 158.</summary>
		private void RXR(VaccinePat vaccine) {
			if(vaccine.AdministrationRoute==VaccineAdministrationRoute.None) {
				return;//Unspecified.  Therefore unknown and the entire segment is not required.
			}
			_seg=new SegmentHL7(SegmentNameHL7.RXR);
			_seg.SetField(0,"RXR");
			//RXR-1 Route.  Required.  Cardinality [1..1].  Value set HL70162 (guide page 200). Type CE (guide page 53).
			if(vaccine.AdministrationRoute==VaccineAdministrationRoute.Intradermal) {
				WriteCE(1,"ID","Intradermal","HL70162");
			}
			else if(vaccine.AdministrationRoute==VaccineAdministrationRoute.Intramuscular) {
				WriteCE(1,"IM","Intramuscular","HL70162");
			}
			else if(vaccine.AdministrationRoute==VaccineAdministrationRoute.Nasal) {
				WriteCE(1,"NS","Nasal","HL70162");
			}
			else if(vaccine.AdministrationRoute==VaccineAdministrationRoute.Intravenous) {
				WriteCE(1,"IV","Intravenous","HL70162");
			}
			else if(vaccine.AdministrationRoute==VaccineAdministrationRoute.Oral) {
				WriteCE(1,"PO","Oral","HL70162");
			}
			else if(vaccine.AdministrationRoute==VaccineAdministrationRoute.Subcutaneous) {
				WriteCE(1,"SC","Subcutaneous","HL70162");
			}
			else if(vaccine.AdministrationRoute==VaccineAdministrationRoute.Transdermal) {
				WriteCE(1,"TD","Transdermal","HL70162");
			}
			else {//Other
				WriteCE(1,"OTH","Other","HL70162");
			}
			//RXR-2 Administration Site.  Required if known.  Cardinality [0..1].  Value set HL70163 (guide page 201, details where the vaccine was physically administered on the patient's body).
			if(vaccine.AdministrationSite==VaccineAdministrationSite.LeftThigh) {
				WriteCE(2,"LT","LeftThigh","HL70163");
			}
			else if(vaccine.AdministrationSite==VaccineAdministrationSite.LeftVastusLateralis) {
				WriteCE(2,"LVL","LeftVastusLateralis","HL70163");
			}
			else if(vaccine.AdministrationSite==VaccineAdministrationSite.LeftGluteousMedius) {
				WriteCE(2,"LG","LeftGluteousMedius","HL70163");
			}
			else if(vaccine.AdministrationSite==VaccineAdministrationSite.LeftArm) {
				WriteCE(2,"LA","LeftArm","HL70163");
			}
			else if(vaccine.AdministrationSite==VaccineAdministrationSite.LeftDeltoid) {
				WriteCE(2,"LD","LeftDeltoid","HL70163");
			}
			else if(vaccine.AdministrationSite==VaccineAdministrationSite.LeftLowerForearm) {
				WriteCE(2,"LLFA","LeftLowerForearm","HL70163");
			}
			else if(vaccine.AdministrationSite==VaccineAdministrationSite.RightThigh) {
				WriteCE(2,"RT","RightThigh","HL70163");
			}
			else if(vaccine.AdministrationSite==VaccineAdministrationSite.RightVastusLateralis) {
				WriteCE(2,"RVL","RightVastusLateralis","HL70163");
			}
			else if(vaccine.AdministrationSite==VaccineAdministrationSite.RightGluteousMedius) {
				WriteCE(2,"RG","RightGluteousMedius","HL70163");
			}
			else if(vaccine.AdministrationSite==VaccineAdministrationSite.RightArm) {
				WriteCE(2,"RA","RightArm","HL70163");
			}			
			else if(vaccine.AdministrationSite==VaccineAdministrationSite.RightDeltoid) {
				WriteCE(2,"RD","RightArm","HL70163");
			}
			else if(vaccine.AdministrationSite==VaccineAdministrationSite.RightLowerForearm) {
				WriteCE(2,"RLFA","RightLowerForearm","HL70163");
			}			
			//RXR-3 Administration Device.  Optional.
			//RXR-4 Administration Method.  Optional.
			//RXR-5 Routing Instruction.  Optional.
			//RXR-6 Administration Site Modifier.  Optional.
			_msg.Segments.Add(_seg);
		}
Пример #26
0
        private void RXA(VaccinePat vaccine)
        {
            VaccineDef vaccineDef = VaccineDefs.GetOne(vaccine.VaccineDefNum);

            seg = new SegmentHL7(SegmentName.RXA);
            seg.SetField(0, "RXA");
            seg.SetField(1, "0");           //fixed
            seg.SetField(2, "1");           //fixed
            seg.SetField(3, vaccine.DateTimeStart.ToString("yyyyMMddHHmm"));
            seg.SetField(4, vaccine.DateTimeEnd.ToString("yyyyMMddHHmm"));
            seg.SetField(5, vaccineDef.CVXCode, vaccineDef.VaccineName, "HL70292");
            if (vaccine.AdministeredAmt == 0)
            {
                seg.SetField(6, "999");
            }
            else
            {
                seg.SetField(6, vaccine.AdministeredAmt.ToString());
            }
            if (vaccine.DrugUnitNum != 0)
            {
                DrugUnit drugUnit = DrugUnits.GetOne(vaccine.DrugUnitNum);
                seg.SetField(7, drugUnit.UnitIdentifier, drugUnit.UnitText, "ISO+");
            }
            seg.SetField(15, vaccine.LotNumber);           //optional.
            //17-Manufacturer.  Is this really optional?
            if (vaccineDef.DrugManufacturerNum != 0)       //always?
            {
                DrugManufacturer manufacturer = DrugManufacturers.GetOne(vaccineDef.DrugManufacturerNum);
                seg.SetField(17, manufacturer.ManufacturerCode, manufacturer.ManufacturerName, "HL70227");
            }
            seg.SetField(21, "A");           //21-Action code, A=Add
            msg.Segments.Add(seg);
        }
Пример #27
0
		///<summary>Patient Visit segment.  Used by Registration/Patient Administration applications to communicate information on a visit-specific basis.  Guide page 51.</summary>
		private void PV1() {
			_seg=new SegmentHL7(SegmentNameHL7.PV1);
			_seg.SetField(0,"PV1");
			_seg.SetField(1,"1");//PV1-1 SET ID - PV1.  Required if known (length 1..4).  Must be set to "1".
			//PV1-2 Patient Class.  Optional.
			//PV1-3 Assigned Patient Location.  Optional.
			//PV1-4 Admission Type.  Optional.
			//PV1-5 Pre-admit Number.  No longer used.
			//PV1-6 Prior Patient Location.  No longer used.
			//PV1-7 Attending Doctor.  No longer used.
			//PV1-8 Referring Doctor.  No longer used.
			//PV1-9 Consulting Doctor.  No longer used.
			//PV1-10 Hospital Service.  Optional.
			//PV1-11 Temporary Location.  No longer used.
			//PV1-12 Preadmit Test Indicator.  No longer used.
			//PV1-13 Re-admission Indicator.  No longer used.
			//PV1-14 Admit Source.  Optional.
			//PV1-15 Ambulatory Status.  Optional.
			//PV1-16 VIP Indicator.  No longer used.
			//PV1-17 Admitting Doctor.  No longer used.
			//PV1-18 Patient Type.  No longer used.
			//PV1-19 Visit Number.  Required (length up to 478).  Cardinality [1..1].
			_seg.SetField(19,
				_appt.AptNum.ToString(),//PV1-19.1 ID Number.  Required (length 1..15).  Unique identifier for patient visit.
				"",//PV1-19.2 Check Digit.  No longer used.
				"",//PV1-19.3 Check Digit Scheme.  No longer used.
				"",//PV1-19.4 Assigning Authority.  Optional.
				"VN"//PV1-19.5 Identifier Type Code.  Required (length 1..5).  Identifier type corresponding to the ID number from PV1-19.1.  VN=Visit Number.
				//PV1-19.6 Assigning Facility.  Optional.
				//PV1-19.7 Effective Date.  No longer used.
				//PV1-19.8 Expiration Date.  No longer used.
				//PV1-19.9 Assigning Jurisdiction.  No longer used.
				//PV1-19.10 Assigning Facility.  No longer used.
			);
			//PV1-20 Financial Class.  No longer used.
			//PV1-21 Charge Price Indicator.  No longer used.
			//PV1-22 Courtesy Code.  No longer used.
			//PV1-23 Credit Rating.  No longer used.
			//PV1-24 Contract Code.  No longer used.
			//PV1-25 Contract Effective Date.  No longer used.
			//PV1-26 Contract Amount.  No longer used.
			//PV1-27 Contract Period.  No longer used.
			//PV1-28 Interest Code.  No longer used.
			//PV1-29 Transfer to Bad Debt Code.  No longer used.
			//PV1-30 Transfer to Bad Debt Date.  No longer used.
			//PV1-31 Bad Debt Agency Code.  No longer used.
			//PV1-32 Bad Debt Transfer Amount.  No longer used.
			//PV1-33 Bad Debt Recovery Amount.  No longer used.
			//PV1-34 Delete Account Indicator.  No longer used.
			//PV1-35 Delete Account Date.  No longer used.
			//PV1-36 Discharge Disposition.  Required if known (length 1..3).  Cardinality [0..1].  Discharge Disposition HL7 table.
			//PV1-37 Discharged to Location.  No longer used.
			//PV1-38 Diet Type.  No longer used.
			//PV1-39 Servicing Facility.  No longer used.
			//PV1-40 Bed Status.  No longer used.
			//PV1-41 Account Status.  No longer used.
			//PV1-42 Pending Location.  No longer used.
			//PV1-43 Prior Temporary Location.  No longer used.
			_seg.SetField(44,_appt.AptDateTime.ToString("yyyyMMddhhmm"));//PV1-44 Admit Date/Time.  Required (length 12..26).  Date and time of the patient presentation.
			//PV1-45 Discharge Date/Time.  Optional.
			//PV1-46 Current Patient Balance.  No longer used.
			//PV1-47 Total Charges.  No longer used.
			//PV1-48 Total Adjustments.  No longer used.
			//PV1-49 Total Payments.  No longer used.
			//PV1-50 Alternate Visit ID.  No longer used.
			//PV1-51 Visit Indicator.  No longer used.
			//PV1-52 Other Healthcare Provider.  No longer used.
			_msg.Segments.Add(_seg);
		}
Пример #28
0
        ///<summary>Returns null if no HL7 def is enabled or no SRR is defined in the enabled def.  An SRR - Schedule Request Response message is sent when an SRM - Schedule Request Message is received.  The SRM is acknowledged just like any inbound message, but the SRR notifies the placer application that the requested modification took place.  Currently the only appointment modifications allowed are updating the appt note, setting the dentist and hygienist, updating the confirmation status, and changing the ClinicNum.  Setting the appointment status to Broken is also supported.</summary>
        public static MessageHL7 GenerateSRR(Patient pat, Appointment apt, EventTypeHL7 eventType, string controlId, bool isAck, string ackEvent)
        {
            HL7Def hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find an outbound SRR message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.SRR && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    break;
                }
            }
            if (hl7DefMessage == null)           //SRR message type is not defined so do nothing and return
            {
                return(null);
            }
            if (PrefC.GetBool(PrefName.ShowFeaturePatientClone))
            {
                pat = Patients.GetOriginalPatientForClone(pat);
            }
            MessageHL7 msgHl7  = new MessageHL7(MessageTypeHL7.SRR);
            Provider   provPri = Providers.GetProv(apt.ProvNum);

            //go through each segment in the def
            for (int i = 0; i < hl7DefMessage.hl7DefSegments.Count; i++)
            {
                List <Provider> listProvs = new List <Provider>();
                listProvs.Add(provPri);
                if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.AIP && apt.ProvHyg > 0)
                {
                    listProvs.Add(Providers.GetProv(apt.ProvHyg));
                }
                for (int j = 0; j < listProvs.Count; j++)           //AIP will be repeated if there is a dentist and a hygienist on the appt
                {
                    Provider   prov = listProvs[j];
                    SegmentHL7 seg  = new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
                    for (int k = 0; k < hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count; k++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FixedText);
                        }
                        else
                        {
                            string fieldValue = "";
                            if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.MSA)
                            {
                                fieldValue = FieldConstructor.GenerateFieldACK(hl7Def, fieldName, controlId, isAck, ackEvent);
                            }
                            else
                            {
                                fieldValue = FieldConstructor.GenerateFieldSRR(hl7Def, fieldName, pat, prov, apt, j + 1, eventType, seg.Name);
                            }
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, fieldValue);
                        }
                    }
                    msgHl7.Segments.Add(seg);
                }
            }
            return(msgHl7);
        }
Пример #29
0
		///<summary>Returns null if there is no HL7Def enabled or if there is no outbound SIU defined for the enabled HL7Def.</summary>
		public static MessageHL7 GenerateSIU(Patient pat,Patient guar,EventTypeHL7 eventType,Appointment apt) {
			HL7Def hl7Def=HL7Defs.GetOneDeepEnabled();
			if(hl7Def==null) {
				return null;
			}
			//find an outbound SIU message in the def
			HL7DefMessage hl7DefMessage=null;
			for(int i=0;i<hl7Def.hl7DefMessages.Count;i++) {
				if(hl7Def.hl7DefMessages[i].MessageType==MessageTypeHL7.SIU && hl7Def.hl7DefMessages[i].InOrOut==InOutHL7.Outgoing) {
					hl7DefMessage=hl7Def.hl7DefMessages[i];
					//continue;
					break;
				}
			}
			if(hl7DefMessage==null) {//SIU message type is not defined so do nothing and return
				return null;
			}
			if(apt==null) {//SIU messages must have an appointment
				return null;
			}
			if(PrefC.GetBool(PrefName.ShowFeaturePatientClone)) {
				Patient patClone;
				Patient patNonClone;
				List<Patient> listAmbiguousMatches;
				Patients.GetCloneAndNonClone(pat,out patClone,out patNonClone,out listAmbiguousMatches);
				if(patNonClone!=null) {
					pat=patNonClone;
				}
			}
			MessageHL7 messageHL7=new MessageHL7(MessageTypeHL7.SIU);
			Provider prov=Providers.GetProv(apt.ProvNum);
			for(int i=0;i<hl7DefMessage.hl7DefSegments.Count;i++) {
				int repeatCount=1;
				//AIP segment can repeat, once for the dentist on the appt and once for the hygienist
				if(hl7DefMessage.hl7DefSegments[i].SegmentName==SegmentNameHL7.AIP && apt.ProvHyg>0) {
					repeatCount=2;
				}
				for(int j=0;j<repeatCount;j++) {//AIP will be repeated if there is a dentist and a hygienist on the appt
					if(j>0) {
						prov=Providers.GetProv(apt.ProvHyg);
						if(prov==null) {
							break;//shouldn't happen, apt.ProvHyg would have to be set to an invalid ProvNum on the appt, just in case
						}
					}
					SegmentHL7 seg=new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
					seg.SetField(0,hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
					for(int k=0;k<hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count;k++) {
						string fieldName=hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FieldName;
						if(fieldName=="") {//If fixed text instead of field name just add text to segment
							seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos,hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FixedText);
						}
						else {
							string fieldValue=FieldConstructor.GenerateFieldSIU(hl7Def,fieldName,pat,prov,guar,apt,j+1,eventType,seg.Name);
							seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos,fieldValue);
						}
					}
					messageHL7.Segments.Add(seg);
				}
			}
			return messageHL7;
		}
Пример #30
0
		///<summary>Returns null if there is no HL7Def enabled or if there is no outbound DFT defined for the enabled HL7Def.</summary>
		public static MessageHL7 GenerateDFT(List<Procedure> listProcs,EventTypeHL7 eventType,Patient pat,Patient guar,long aptNum,string pdfDescription,string pdfDataString) {
			//In \\SERVERFILES\storage\OPEN DENTAL\Programmers Documents\Standards (X12, ADA, etc)\HL7\Version2.6\V26_CH02_Control_M4_JAN2007.doc
			//On page 28, there is a Message Construction Pseudocode as well as a flowchart which might help.
			MessageHL7 msgHl7=new MessageHL7(MessageTypeHL7.DFT);
			HL7Def hl7Def=HL7Defs.GetOneDeepEnabled();
			if(hl7Def==null) {
				return null;
			}
			//find a DFT message in the def
			HL7DefMessage hl7DefMessage=null;
			for(int i=0;i<hl7Def.hl7DefMessages.Count;i++) {
				if(hl7Def.hl7DefMessages[i].MessageType==MessageTypeHL7.DFT && hl7Def.hl7DefMessages[i].InOrOut==InOutHL7.Outgoing) {
					hl7DefMessage=hl7Def.hl7DefMessages[i];
					//continue;
					break;
				}
			}
			if(hl7DefMessage==null) {//DFT message type is not defined so do nothing and return
				return null;
			}
			if(PrefC.GetBool(PrefName.ShowFeaturePatientClone)) {
				Patient patClone;
				Patient patNonClone;
				List<Patient> listAmbiguousMatches;
				Patients.GetCloneAndNonClone(pat,out patClone,out patNonClone,out listAmbiguousMatches);
				if(patNonClone!=null) {
					pat=patNonClone;
				}
			}
			Provider prov=Providers.GetProv(Patients.GetProvNum(pat));
			Appointment apt=Appointments.GetOneApt(aptNum);
			List<PatPlan> listPatPlans=PatPlans.Refresh(pat.PatNum);
			for(int i=0;i<hl7DefMessage.hl7DefSegments.Count;i++) {
				int repeatCount=1;
				if(hl7DefMessage.hl7DefSegments[i].SegmentName==SegmentNameHL7.FT1) {
					repeatCount=listProcs.Count;
				}
				else if(hl7DefMessage.hl7DefSegments[i].SegmentName==SegmentNameHL7.IN1) {
					repeatCount=listPatPlans.Count;
				}
				//for example, countRepeat can be zero in the case where we are only sending a PDF of the TP to eCW, and no procs.
				//or the patient does not have any current insplans for IN1 segments
				for(int j=0;j<repeatCount;j++) {//FT1 is optional and can repeat so add as many FT1's as procs in procList, IN1 is optional and can repeat as well, repeat for the number of patplans in patplanList
					if(hl7DefMessage.hl7DefSegments[i].SegmentName==SegmentNameHL7.FT1 && listProcs.Count>j) {
						prov=Providers.GetProv(listProcs[j].ProvNum);
					}
					Procedure proc=null;
					if(listProcs.Count>j) {//procList could be an empty list
						proc=listProcs[j];
					}
					PatPlan patPlanCur=null;
					InsPlan insPlanCur=null;
					InsSub insSubCur=null;
					Carrier carrierCur=null;
					Patient subscriber=null;
					if(hl7DefMessage.hl7DefSegments[i].SegmentName==SegmentNameHL7.IN1) {
						patPlanCur=listPatPlans[j];
						insSubCur=InsSubs.GetOne(patPlanCur.InsSubNum);
						insPlanCur=InsPlans.RefreshOne(insSubCur.PlanNum);
						carrierCur=Carriers.GetCarrier(insPlanCur.CarrierNum);
						subscriber=Patients.GetPat(insSubCur.Subscriber);
					}
					SegmentHL7 seg=new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
					seg.SetField(0,hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
					for(int f=0;f<hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count;f++) {
						string fieldName=hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].FieldName;
						if(fieldName=="") {//If fixed text instead of field name just add text to segment
							seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].OrdinalPos,hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].FixedText);
						}
						else {
							string fieldValue="";
							if(hl7DefMessage.hl7DefSegments[i].SegmentName==SegmentNameHL7.IN1) {
								fieldValue=FieldConstructor.GenerateFieldIN1(hl7Def,fieldName,j+1,patPlanCur,insSubCur,insPlanCur,carrierCur,listPatPlans.Count,subscriber);
							}
							else {
								fieldValue=FieldConstructor.GenerateField(hl7Def,fieldName,MessageTypeHL7.DFT,pat,prov,proc,guar,apt,j+1,eventType,
								 pdfDescription,pdfDataString,MessageStructureHL7.DFT_P03,seg.Name);
							}
							seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].OrdinalPos,fieldValue);
						}
					}
					msgHl7.Segments.Add(seg);
				}
			}
			return msgHl7;
		}
Пример #31
0
 private void ORC()
 {
     seg=new SegmentHL7(SegmentName.ORC);
     seg.SetField(0,"ORC");
     seg.SetField(1,"RE");//fixed
     msg.Segments.Add(seg);
 }
Пример #32
0
 ///<summary>Patient identification.</summary>
 private void PID(Patient pat)
 {
     seg = new SegmentHL7(SegmentNameHL7.PID);
     seg.SetField(0, "PID");
     seg.SetField(1, "1");
     seg.SetField(2, pat.ChartNumber);           //Account number.  eCW requires this to be the same # as came in on PID.4.
     seg.SetField(3, pat.PatNum.ToString());     //??what is this MRN?
     seg.SetField(5, pat.LName, pat.FName, pat.MiddleI);
     //we assume that dob is always valid because eCW should always pass us a dob.
     seg.SetField(7, pat.Birthdate.ToString("yyyyMMdd"));
     seg.SetField(8, ConvertGender(pat.Gender));
     seg.SetField(10, ConvertRace(PatientRaces.GetPatientRaceOldFromPatientRaces(pat.PatNum)));           //Passes in the deprecated PatientRaceOld enum retrieved from the PatientRace table.
     seg.SetField(11, pat.Address, pat.Address2, pat.City, pat.State, pat.Zip);
     seg.SetField(13, ConvertPhone(pat.HmPhone));
     seg.SetField(14, ConvertPhone(pat.WkPhone));
     seg.SetField(16, ConvertMaritalStatus(pat.Position));
     seg.SetField(19, pat.SSN);
     msg.Segments.Add(seg);
 }
Пример #33
0
 ///<summary>Patient identification.</summary>
 private void PID(Patient pat)
 {
     seg=new SegmentHL7(SegmentName.PID);
     seg.SetField(0,"PID");
     seg.SetField(3,pat.PatNum.ToString(),"","","","MR");//component 5 is "identifier type code".  See table 0203. MR=medical record number
     seg.SetField(5,pat.LName,pat.FName);
     if(pat.Birthdate.Year>1880) {//7: dob optional
         seg.SetField(7,pat.Birthdate.ToString("yyyyMMdd"));
     }
     seg.SetField(8,ConvertGender(pat.Gender));
     seg.SetField(10,ConvertRace(pat.Race));
     seg.SetField(11,pat.Address,pat.Address2,pat.City,pat.State,pat.Zip,"","M");//M is for mailing.
     seg.SetField(13,ConvertPhone(pat.HmPhone));
     seg.SetField(22,ConvertEthnicGroup(pat.Race));
     msg.Segments.Add(seg);
 }
Пример #34
0
        ///<summary>Financial transaction segment.</summary>
        private void FT1(List <Procedure> listProcs, bool justPDF)
        {
            if (justPDF)
            {
                return;                //FT1 segment is not necessary when sending only a PDF.
            }
            ProcedureCode procCode;

            for (int i = 0; i < listProcs.Count; i++)
            {
                seg = new SegmentHL7(SegmentNameHL7.FT1);
                seg.SetField(0, "FT1");
                seg.SetField(1, (i + 1).ToString());
                seg.SetField(4, listProcs[i].ProcDate.ToString("yyyyMMdd"));
                seg.SetField(5, listProcs[i].ProcDate.ToString("yyyyMMdd"));
                seg.SetField(6, "CG");
                seg.SetField(10, "1.0");
                seg.SetField(16, "");               //location code and description???
                seg.SetField(19, listProcs[i].DiagnosticCode);
                Provider prov = Providers.GetProv(listProcs[i].ProvNum);
                seg.SetField(20, prov.EcwID, prov.LName, prov.FName, prov.MI);            //performed by provider.
                seg.SetField(21, prov.EcwID, prov.LName, prov.FName, prov.MI);            //ordering provider.
                seg.SetField(22, listProcs[i].ProcFee.ToString("F2"));
                procCode = ProcedureCodes.GetProcCode(listProcs[i].CodeNum);
                if (procCode.ProcCode.Length > 5 && procCode.ProcCode.StartsWith("D"))
                {
                    seg.SetField(25, procCode.ProcCode.Substring(0, 5));                  //Remove suffix from all D codes.
                }
                else
                {
                    seg.SetField(25, procCode.ProcCode);
                }
                if (procCode.TreatArea == TreatmentArea.ToothRange)
                {
                    seg.SetField(26, listProcs[i].ToothRange, "");
                }
                else if (procCode.TreatArea == TreatmentArea.Surf)              //probably not necessary
                {
                    seg.SetField(26, Tooth.ToInternat(listProcs[i].ToothNum), Tooth.SurfTidyForClaims(listProcs[i].Surf, listProcs[i].ToothNum));
                }
                //this property will not exist if using Oracle, eCW will never use Oracle
                else if (procCode.TreatArea == TreatmentArea.Quad && ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.eClinicalWorks), "IsQuadAsToothNum") == "1")
                {
                    seg.SetField(26, listProcs[i].Surf, "");
                }
                else
                {
                    seg.SetField(26, Tooth.ToInternat(listProcs[i].ToothNum), listProcs[i].Surf);
                }
                msg.Segments.Add(seg);
            }
        }
Пример #35
0
 private void RXA(VaccinePat vaccine)
 {
     VaccineDef vaccineDef=VaccineDefs.GetOne(vaccine.VaccineDefNum);
     seg=new SegmentHL7(SegmentName.RXA);
     seg.SetField(0,"RXA");
     seg.SetField(1,"0");//fixed
     seg.SetField(2,"1");//fixed
     seg.SetField(3,vaccine.DateTimeStart.ToString("yyyyMMddHHmm"));
     seg.SetField(4,vaccine.DateTimeEnd.ToString("yyyyMMddHHmm"));
     seg.SetField(5,vaccineDef.CVXCode,vaccineDef.VaccineName,"HL70292");
     if(vaccine.AdministeredAmt==0){
         seg.SetField(6,"999");
     }
     else{
         seg.SetField(6,vaccine.AdministeredAmt.ToString());
     }
     if(vaccine.DrugUnitNum!=0){
         DrugUnit drugUnit=DrugUnits.GetOne(vaccine.DrugUnitNum);
         seg.SetField(7,drugUnit.UnitIdentifier,drugUnit.UnitText,"ISO+");
     }
     seg.SetField(15,vaccine.LotNumber);//optional.
     //17-Manufacturer.  Is this really optional?
     if(vaccineDef.DrugManufacturerNum!=0) {//always?
         DrugManufacturer manufacturer=DrugManufacturers.GetOne(vaccineDef.DrugManufacturerNum);
         seg.SetField(17,manufacturer.ManufacturerCode,manufacturer.ManufacturerName,"HL70227");
     }
     seg.SetField(21,"A");//21-Action code, A=Add
     msg.Segments.Add(seg);
 }
Пример #36
0
		///<summary>Observation Result segment.  Required if known.  The basic format is question and answer.  Guide page 116.</summary>
		private void OBX(VaccinePat vaccine) {
			List<VaccineObs> listVaccineObservations=VaccineObses.GetForVaccine(vaccine.VaccinePatNum);
			for(int i=0;i<listVaccineObservations.Count;i++) {
				VaccineObs vaccineObs=listVaccineObservations[i];
				_seg=new SegmentHL7(SegmentNameHL7.OBX);
				_seg.SetField(0,"OBX");
				_seg.SetField(1,(i+1).ToString());//OBX-1 Set ID - OBX.  Required (length 1..4).  Cardinality [1..1].
				//OBX-2 Value Type.  Required (length 2..3).  Cardinality [1..1].  Value Set HL70125 (constrained, not in guide).  CE=Coded Entry,DT=Date,NM=Numeric,ST=String,TS=Time Stamp (Date & Time).
				if(vaccineObs.ValType==VaccineObsType.Dated) {
					_seg.SetField(2,"DT");
				}
				else if(vaccineObs.ValType==VaccineObsType.Numeric) {
					_seg.SetField(2,"NM");
				}
				else if(vaccineObs.ValType==VaccineObsType.Text) {
					_seg.SetField(2,"ST");
				}
				else if(vaccineObs.ValType==VaccineObsType.DateAndTime) {
					_seg.SetField(2,"TS");
				}
				else { //vaccineObs.ValType==VaccineObsType.Coded
					_seg.SetField(2,"CE");
				}
				//OBX-3 Observation Identifier.  Required.  Cardinality [1..1].  Value set NIP003 (25 items).  Type CE.  Purpose is to pose the question that is answered by OBX-5.
				if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.DatePublished) {
					WriteCE(3,"29768-9","Date vaccine information statement published","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.DatePresented) {
					WriteCE(3,"29769-7","Date vaccine information statement presented","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.DatePrecautionExpiration) {
					WriteCE(3,"30944-3","Date of vaccination temporary contraindication and or precaution expiration","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.Precaution) {
					WriteCE(3,"30945-0","Vaccination contraindication and or precaution","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.DatePrecautionEffective) {
					WriteCE(3,"30946-8","Date vaccination contraindication and or precaution effective","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.TypeOf) {
					WriteCE(3,"30956-7","Vaccine Type","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.FundsPurchasedWith) {
					WriteCE(3,"30963-3","Funds vaccine purchased with","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.DoseNumber) {
					WriteCE(3,"30973-2","Dose number","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.NextDue) {
					WriteCE(3,"30979-9","Vaccines due next","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.DateDue) {
					WriteCE(3,"30980-7","Date vaccine due","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.DateEarliestAdminister) {
					WriteCE(3,"30981-5","Earliest date to give","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.ReasonForcast) {
					WriteCE(3,"30982-3","Reason applied by forcast logic to project this vaccine","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.Reaction) {
					WriteCE(3,"31044-1","Reaction","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.ComponentType) {
					WriteCE(3,"38890-0","Vaccine component type","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.TakeResponseType) {
					WriteCE(3,"46249-9","Vaccination take-response type","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.DateTakeResponse) {
					WriteCE(3,"46250-7","Vaccination take-response date","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.ScheduleUsed) {
					WriteCE(3,"59779-9","Immunization schedule used","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.Series) {
					WriteCE(3,"59780-7","Immunization series","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.DoseValidity) {
					WriteCE(3,"59781-5","Dose validity","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.NumDosesPrimary) {
					WriteCE(3,"59782-3","Number of doses in primary immunization series","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.StatusInSeries) {
					WriteCE(3,"59783-1","Status in immunization series","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.DiseaseWithImmunity) {
					WriteCE(3,"59784-9","Disease with presumed immunity","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.Indication) {
					WriteCE(3,"59785-6","Indication for Immunization","LN");
				}
				else if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.FundPgmEligCat) {
					WriteCE(3,"64994-7","Vaccine funding program eligibility category","LN");
				}
				else { //vaccineObs.IdentifyingCode==VaccineObsIdentifier.DocumentType
					WriteCE(3,"69764-9","Document type","LN");
				}
				//OBX-4 Observation Sub-ID.  Required (length 1..20).  Cardinality [1..1].  Type ST.
				if(vaccineObs.VaccineObsNumGroup==0) {
					_seg.SetField(4,vaccineObs.VaccineObsNum.ToString());
				}
				else {//vaccineObs.VaccineObsNumGroup!=0
					_seg.SetField(4,vaccineObs.VaccineObsNumGroup.ToString());
				}
				//OBX-5 Observation Value.  Required. Cardinality [1..1].  Value set varies, depending on the value of OBX-2 (Use type CE if OBX-2 is "CE", otherwise treat as a string).  Purpose is to answer the quesiton posed by OBX-3.
				if(vaccineObs.ValType==VaccineObsType.Coded) {
					string codeDescript=vaccineObs.ValReported.Trim();//If we do not know the description, then the code will also be placed into the description. The testing tool required non-empty entries.
					if(vaccineObs.ValCodeSystem==VaccineObsValCodeSystem.CVX) {
						Cvx cvx=Cvxs.GetByCode(vaccineObs.ValReported);
						codeDescript=cvx.Description;
					}
					else if(vaccineObs.ValCodeSystem==VaccineObsValCodeSystem.HL70064) {
						if(vaccineObs.ValReported.ToUpper()=="V01") {
							codeDescript="Not VFC eligible";
						}
						else if(vaccineObs.ValReported.ToUpper()=="V02") {
							codeDescript="VFC eligible-Medicaid/Medicaid Managed Care";
						}
						else if(vaccineObs.ValReported.ToUpper()=="V03") {
							codeDescript="VFC eligible- Uninsured";
						}
						else if(vaccineObs.ValReported.ToUpper()=="V04") {
							codeDescript="VFC eligible- American Indian/Alaskan Native";
						}
						else if(vaccineObs.ValReported.ToUpper()=="V05") {
							codeDescript="VFC eligible-Federally Qualified Health Center Patient (under-insured)";
						}
						else if(vaccineObs.ValReported.ToUpper()=="V06") {
							codeDescript="Deprecated [VFC eligible- State specific eligibility (e.g. S-CHIP plan)]";
						}
						else if(vaccineObs.ValReported.ToUpper()=="V07") {
							codeDescript="Local-specific eligibility";
						}
						else if(vaccineObs.ValReported.ToUpper()=="V08") {
							codeDescript="Deprecated [Not VFC eligible-underinsured]";
						}
					}
					WriteCE(5,vaccineObs.ValReported.Trim(),codeDescript,vaccineObs.ValCodeSystem.ToString());
				}
				else if(vaccineObs.ValType==VaccineObsType.Dated) {
					DateTime dateVal=DateTime.Parse(vaccineObs.ValReported.Trim());
					_seg.SetField(5,dateVal.ToString("yyyyMMdd"));
				}
				else if(vaccineObs.ValType==VaccineObsType.Numeric) {
					_seg.SetField(5,vaccineObs.ValReported.Trim());
				}
				else if(vaccineObs.ValType==VaccineObsType.DateAndTime) {
					DateTime dateVal=DateTime.Parse(vaccineObs.ValReported.Trim());
					string strDateOut=dateVal.ToString("yyyyMMdd");
					//The testing tool threw errors when there were trailing zeros, even though technically valid.
					if(dateVal.Second>0) {
						strDateOut+=dateVal.ToString("HHmmss");
					}
					else if(dateVal.Minute>0) {
						strDateOut+=dateVal.ToString("HHmm");
					}
					else if(dateVal.Hour>0) {
						strDateOut+=dateVal.ToString("HH");
					}
					_seg.SetField(5,strDateOut);
				}
				else { //vaccineObs.ValType==VaccineObsType.Text
					_seg.SetField(5,vaccineObs.ValReported);
				}
				//OBX-6 Units.  Required if OBX-2 is "NM" or "SN" (SN appears to be missing from definition).
				if(vaccineObs.ValType==VaccineObsType.Numeric) {
					Ucum ucum=Ucums.GetByCode(vaccineObs.UcumCode);
					WriteCE(6,ucum.UcumCode,ucum.Description,"UCUM");
				}
				//OBX-7 References Range.  Optional.
				//OBX-8 Abnormal Flags.  Optional.
				//OBX-9 Probability.  Optional.
				//OBX-10 Nature of Abnormal Test.  Optional.
				_seg.SetField(11,"F");//OBX-11 Observation Result Status.  Required (length 1..1).  Cardinality [1..1].  Value set HL70085 (constrained, guide page 198).  We are expected to use value F=Final.
				//OBX-12 Effective Date of Reference Range Values.  Optional.
				//OBX-13 User Defined Access Checks.  Optional.
				//OBX-14 Date/Time of the Observation.  Required if known.  Cardinality [0..1].
				if(vaccineObs.DateObs.Year>1880) {
					_seg.SetField(14,vaccineObs.DateObs.ToString("yyyyMMdd"));
				}
				//OBX-15 Producer's Reference.  Optional.
				//OBX-16 Responsible Observer.  Optional.
				//OBX-17 Observation Method.  Required if OBX-3.1 is “64994-7”.  Value set CDCPHINVS. Type CE.
				if(vaccineObs.IdentifyingCode==VaccineObsIdentifier.FundPgmEligCat) {
					_seg.SetField(17,vaccineObs.MethodCode.Trim(),"","CDCPHINVS");
				}
				//OBX-18 Equipment Instance Identifier.  Optional.
				//OBX-19 Date/Time of the Analysis.  Optional.
				//OBX-20 Reserved for harmonization with V2.6.  Optional.
				//OBX-21 Reserved for harmonization with V2.6.  Optional.
				//OBX-22 Reserved for harmonization with V2.6.  Optional.
				//OBX-23 Performing Organization Name.  Optional.
				//OBX-24 Performing Organization Address.  Optional.
				//OBX-25 Performing Organization Medical Director.  Optional.
				_msg.Segments.Add(_seg);
			}
		}
Пример #37
0
        ///<summary>Returns null if there is no HL7Def enabled or if there is no outbound SIU defined for the enabled HL7Def.</summary>
        public static MessageHL7 GenerateSIU(Patient pat, Patient guar, EventTypeHL7 eventType, Appointment apt)
        {
            HL7Def hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find an outbound SIU message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.SIU && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    //continue;
                    break;
                }
            }
            if (hl7DefMessage == null)           //SIU message type is not defined so do nothing and return
            {
                return(null);
            }
            if (apt == null)           //SIU messages must have an appointment
            {
                return(null);
            }
            if (PrefC.GetBool(PrefName.ShowFeaturePatientClone))
            {
                pat = Patients.GetOriginalPatientForClone(pat);
            }
            MessageHL7 messageHL7 = new MessageHL7(MessageTypeHL7.SIU);
            Provider   prov       = Providers.GetProv(apt.ProvNum);

            for (int i = 0; i < hl7DefMessage.hl7DefSegments.Count; i++)
            {
                int repeatCount = 1;
                //AIP segment can repeat, once for the dentist on the appt and once for the hygienist
                if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.AIP && apt.ProvHyg > 0)
                {
                    repeatCount = 2;
                }
                for (int j = 0; j < repeatCount; j++)           //AIP will be repeated if there is a dentist and a hygienist on the appt
                {
                    if (j > 0)
                    {
                        prov = Providers.GetProv(apt.ProvHyg);
                        if (prov == null)
                        {
                            break;                            //shouldn't happen, apt.ProvHyg would have to be set to an invalid ProvNum on the appt, just in case
                        }
                    }
                    SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
                    for (int k = 0; k < hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count; k++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FixedText);
                        }
                        else
                        {
                            string fieldValue = FieldConstructor.GenerateFieldSIU(hl7Def, fieldName, pat, prov, guar, apt, j + 1, eventType, seg.Name);
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, fieldValue);
                        }
                    }
                    messageHL7.Segments.Add(seg);
                }
            }
            return(messageHL7);
        }
Пример #38
0
		///<summary>Patient Demographic segment.  Required if known.  Additional demographics.  Guide page 132.</summary>
		private void PD1() {
			_seg=new SegmentHL7(SegmentNameHL7.PD1);
			_seg.SetField(0,"PD1");
			//PD1-1 Living Dependency.  Optional.  Cardinality [0..1].
			//PD1-2 Living Arrangement.  Optional.  Cardinality [0..1].
			//PD1-3 Patient Primary Facility.  Optional.  Cardinality [0..1].
			//PD1-4 Patient Primary Care Provider Name & ID Number.  Optional.  Cardinality [0..1].
			//PD1-5 Student Indicator.  Optional.  Cardinality [0..1].
			//PD1-6 Handicap.  Optional.  Cardinality [0..1].
			//PD1-7 Living Will Code.  Optional.  Cardinality [0..1].
			//PD1-8 Organ Donor Code.  Optional.  Cardinality [0..1].
			//PD1-9 Separate Bill.  Optional.  Cardinality [0..1].
			//PD1-10 Duplicate Patient.  Optional.  Cardinality [0..1].
			//PD1-11 Publicity Code.  Required if known (length 2..2).  Cardinality [0..1].  Value set HL70215 (guide page 209).  Type CE.
			if(_pat.PreferRecallMethod==ContactMethod.DoNotCall) {
				WriteCE(11,"07","Recall only - no calls","HL70215");
			}
			else if(_pat.PreferRecallMethod==ContactMethod.None) {
				WriteCE(11,"01","No reminder/Recall","HL70215");
			}
			else {
				WriteCE(11,"02","Reminder/Recall - any method","HL70215");
			}
			//PD1-12 Protection Indicator.  Required if known (length 1..1).  Cardinality [0..1].  Value set HL70136 (guide page 199).  Allowed values are "Y" for yes, "N" for no, or blank for unknown.
			EhrPatient ehrPatient=EhrPatients.Refresh(_pat.PatNum);
			if(ehrPatient.VacShareOk==YN.Yes) {
				_seg.SetField(12,"N");//Do not protect.
			}
			else if(ehrPatient.VacShareOk==YN.No) {
				_seg.SetField(12,"Y");//Protect
			}
			//PD1-13 Protection Indicator Date Effective.  Required if PD1-12 is not blank (length unspecified).  Cardinality [0..1].
			if(ehrPatient.VacShareOk!=YN.Unknown) {
				_seg.SetField(13,_pat.DateTStamp.ToString("yyyyMMdd"));
			}
			//PD1-14 Place of Worship.  Optional (length unspecified).  Cardinality [0..1].
			//PD1-15 Advance Directive Code.  Optional (length unspecified).  Cardinality [0..1].
			//PD1-16 Immunization Registry Status.  Required if known (length unspecified).  Cardinality [0..1].  Value set HL70441 (guide page 232).  The word "registry" refers to the EHR.
			if(_pat.PatStatus==PatientStatus.Patient) {
				_seg.SetField(16,"A");//Active
			}
			else {
				_seg.SetField(16,"I");//Inactive--Unspecified
			}
			//PD1-17 Immunization Registry Status Effective Date.  Required if PD1-16 is not blank.  Cardinality [0..1].
			_seg.SetField(17,DateTime.Today.ToString("yyyyMMdd"));
			//PD1-18 Publicity Code Effective Date.  Required if PD1-11 is not blank.
			_seg.SetField(18,DateTime.Today.ToString("yyyyMMdd"));
			//PD1-19 Military Branch.  Optional.
			//PD1-20 Military Rank/Grade.  Optional.
			//PD1-21 Military Status.  Optional.
			_msg.Segments.Add(_seg);
		}
Пример #39
0
		///<summary>Returns null if no HL7 def is enabled or no ACK is defined in the enabled def.</summary>
		public static MessageHL7 GenerateACK(string controlId,bool isAck,string ackEvent) {
			MessageHL7 messageHL7=new MessageHL7(MessageTypeHL7.ACK);
			messageHL7.ControlId=controlId;
			messageHL7.AckEvent=ackEvent;
			HL7Def hl7Def=HL7Defs.GetOneDeepEnabled();
			if(hl7Def==null) {
				return null;//no def enabled, return null
			}
			//find an ACK message in the def
			HL7DefMessage hl7DefMessage=null;
			for(int i=0;i<hl7Def.hl7DefMessages.Count;i++) {
				if(hl7Def.hl7DefMessages[i].MessageType==MessageTypeHL7.ACK && hl7Def.hl7DefMessages[i].InOrOut==InOutHL7.Outgoing) {
					hl7DefMessage=hl7Def.hl7DefMessages[i];
					break;
				}
			}
			if(hl7DefMessage==null) {//ACK message type is not defined so do nothing and return
				return null;
			}
			//go through each segment in the def
			for(int s=0;s<hl7DefMessage.hl7DefSegments.Count;s++) {
				SegmentHL7 seg=new SegmentHL7(hl7DefMessage.hl7DefSegments[s].SegmentName);
				seg.SetField(0,hl7DefMessage.hl7DefSegments[s].SegmentName.ToString());
				for(int f=0;f<hl7DefMessage.hl7DefSegments[s].hl7DefFields.Count;f++) {
					string fieldName=hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FieldName;
					if(fieldName=="") {//If fixed text instead of field name just add text to segment
						seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos,hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].FixedText);
					}
					else {
						seg.SetField(hl7DefMessage.hl7DefSegments[s].hl7DefFields[f].OrdinalPos,FieldConstructor.GenerateACK(hl7Def,fieldName,controlId,isAck,ackEvent));
					}
				}
				messageHL7.Segments.Add(seg);
			}
			return messageHL7;
		}
Пример #40
0
		///<summary>Pharmacy/Treatment Administration segment.  Required.  Guide page 149.</summary>
		private void RXA(VaccinePat vaccine) {
			_seg=new SegmentHL7(SegmentNameHL7.RXA);
			_seg.SetField(0,"RXA");
			_seg.SetField(1,"0");//RXA-1 Give Sub-ID Counter.  Required.  Must be "0".
			_seg.SetField(2,"1");//RXA-2 Administration Sub-ID Counter.  Required.  Must be "1".
			_seg.SetField(3,vaccine.DateTimeStart.ToString("yyyyMMddHHmm"));//RXA-3 Date/Time Start of Administration.  Required.  This segment can also be used to planned vaccinations.
			if(vaccine.DateTimeEnd.Year>1880) {
				_seg.SetField(4,vaccine.DateTimeEnd.ToString("yyyyMMddHHmm"));//RXA-4 Date/Time End of Administration.  Required if known.  Must be same as RXA-3 or blank.  UI forces RXA-4 and RXA-3 to be equal.  This would be blank if for a planned vaccine.
			}
			//RXA-5 Administered Code.  Required.  Cardinality [1..1].  Type CE (guide page 53).  Must be a CVX code.
			VaccineDef vaccineDef=null;
			if(vaccine.CompletionStatus==VaccineCompletionStatus.NotAdministered) {
				WriteCE(5,"998","no vaccine administered","CVX");
			}
			else {
				vaccineDef=VaccineDefs.GetOne(vaccine.VaccineDefNum);
				Cvx cvx=Cvxs.GetByCode(vaccineDef.CVXCode);
				WriteCE(5,cvx.CvxCode,cvx.Description,"CVX");
			}
			//RXA-6 Administered Amount.  Required (length 1..20).  If amount is not known or not meaningful, then use "999".
			if(vaccine.AdministeredAmt>0) {
				_seg.SetField(6,vaccine.AdministeredAmt.ToString());
			}
			else {
				_seg.SetField(6,"999");//Registries that do not collect administered amount should record the value as "999".
			}
			//RXA-7 Administered Units.  Required if RXA-6 is not "999".  Cadinality [0..1].  Type CE (guide page 53).  Value set HL70396 (guide page 231).  Must be UCUM coding.
			if(vaccine.AdministeredAmt>0 && vaccine.DrugUnitNum!=0) {
				DrugUnit drugUnit=DrugUnits.GetOne(vaccine.DrugUnitNum);
				Ucum ucum=Ucums.GetByCode(drugUnit.UnitIdentifier);
				WriteCE(7,ucum.UcumCode,ucum.Description,"UCUM");//UCUM is not in table HL70396, but it there was a note stating that it was required in the guide and UCUM was required in the test cases.
			}
			//RXA-8 Administered Dosage Form.  Optional.
			//RXA-9 Administration Notes.  Required if RXA-20 is "CP" or "PA".  Value set NIP 0001.  Type CE.
			if(vaccine.CompletionStatus==VaccineCompletionStatus.Complete || vaccine.CompletionStatus==VaccineCompletionStatus.PartiallyAdministered) {
				if(vaccine.AdministrationNoteCode==VaccineAdministrationNote.NewRecord) {
					WriteCE(9,"00","New immunization record","NIP001");
				}
				else if(vaccine.AdministrationNoteCode==VaccineAdministrationNote.HistoricalSourceUnknown) {
					WriteCE(9,"01","Historical information - source unspecified","NIP001");
				}
				else if(vaccine.AdministrationNoteCode==VaccineAdministrationNote.HistoricalOtherProvider) {
					WriteCE(9,"02","Historical information - from other provider","NIP001");
				}
				else if(vaccine.AdministrationNoteCode==VaccineAdministrationNote.HistoricalParentsWrittenRecord) {
					WriteCE(9,"03","Historical information - from parent's written record","NIP001");
				}
				else if(vaccine.AdministrationNoteCode==VaccineAdministrationNote.HistoricalParentsRecall) {
					WriteCE(9,"04","Historical information - from parent's recall","NIP001");
				}
				else if(vaccine.AdministrationNoteCode==VaccineAdministrationNote.HistoricalOtherRegistry) {
					WriteCE(9,"05","Historical information - from other registry","NIP001");
				}
				else if(vaccine.AdministrationNoteCode==VaccineAdministrationNote.HistoricalBirthCertificate) {
					WriteCE(9,"06","Historical information - from birth certificate","NIP001");
				}
				else if(vaccine.AdministrationNoteCode==VaccineAdministrationNote.HistoricalSchoolRecord) {
					WriteCE(9,"07","Historical information - from school record","NIP001");
				}
				else if(vaccine.AdministrationNoteCode==VaccineAdministrationNote.HistoricalPublicAgency) {
					WriteCE(9,"08","Historical information - from public agency","NIP001");
				}
			}
			//RXA-10 Administering Provider.  Required if known.  Type XCN.  This is the person who gave the administration or the vaccinaton.  It is not the ordering clinician.
			Provider provAdministering=Providers.GetProv(vaccine.ProvNumAdminister);//Can be null when vaccine.ProvNumAdminister is zero.
			if(provAdministering!=null) {
				WriteXCN(10,provAdministering.FName,provAdministering.LName,provAdministering.MI,provAdministering.ProvNum.ToString(),cityWhereEntered,stateWhereEntered,"L");
			}
			//RXA-11 Administered-at Location.  Required if known.  Type LA2 (guide page 68).  This is the clinic/site where the vaccine was administered.
			WriteLA2(11,_sendingFacilityName);
			//RXA-12 Administered Per (Time Unit).  Optional.
			//RXA-13 Administered Strength.  Optional.
			//RXA-14 Administered Strength Units.  Optional.
			//RXA-15 Substance Lot Number.  Required if the value in RXA-9.1 is "00".  We decided not to send this field if NotAdministered because we observed such behavior in the testing tool.
			if(vaccine.CompletionStatus!=VaccineCompletionStatus.NotAdministered && vaccine.LotNumber.Trim()!="") {
				_seg.SetField(15,vaccine.LotNumber.Trim());
			}
			//RXA-16 Substance Expiration Date.  Required if RXA-15 is not blank.  Must include at least year and month, but day is not required.  We decided not to send this field if NotAdministered because we observed such behavior in the testing tool.
			if(vaccine.CompletionStatus!=VaccineCompletionStatus.NotAdministered && vaccine.DateExpire.Year>1880) {
				_seg.SetField(16,vaccine.DateExpire.ToString("yyyyMMdd"));
			}
			//RXA-17 Substance Manufacturer Name.  Requred if RXA-9.1 is "00".  Cardinality [0..*].  Value set MVX.  Type CE.
			if(vaccine.CompletionStatus!=VaccineCompletionStatus.NotAdministered && vaccineDef.DrugManufacturerNum!=0) {
				DrugManufacturer manufacturer=DrugManufacturers.GetOne(vaccineDef.DrugManufacturerNum);
				WriteCE(17,manufacturer.ManufacturerCode,manufacturer.ManufacturerName,"MVX");
			}
			//RXA-18 Substance/Treatment Refusal Reason.  Required if RXA-20 is "RE".  Cardinality [0..*].  Required when RXA-20 is "RE", otherwise do not send.  Value set NIP002.
			if(vaccine.RefusalReason==VaccineRefusalReason.ParentalDecision) {
				WriteCE(18,"00","Parental decision","NIP002");
			}
			else if(vaccine.RefusalReason==VaccineRefusalReason.ReligiousExemption) {
				WriteCE(18,"01","Religious exemption","NIP002");
			}
			else if(vaccine.RefusalReason==VaccineRefusalReason.Other) {
				WriteCE(18,"02",vaccine.Note,"NIP002");//The reason is required instead of a generic description for this particular situation.
			}
			else if(vaccine.RefusalReason==VaccineRefusalReason.PatientDecision) {
				WriteCE(18,"03","Patient decision","NIP002");
			}
			//RXA-19 Indication.  Optional.
			//RXA-20 Completion Status.  Required if known (length 2..2).  Value set HL70322 (guide page 225).  CP=Complete, RE=Refused, NA=Not Administered, PA=Partially Administered.
			if(vaccine.CompletionStatus==VaccineCompletionStatus.Refused) {
				_seg.SetField(20,"RE");
			}
			else if(vaccine.CompletionStatus==VaccineCompletionStatus.NotAdministered) {
				_seg.SetField(20,"NA");
			}
			else if(vaccine.CompletionStatus==VaccineCompletionStatus.PartiallyAdministered) {
				_seg.SetField(20,"PA");
			}
			else {//Complete (default)
				_seg.SetField(20,"CP");
			}
			//RXA-21 Action code.  Required if known (length 2..2).  Value set HL70323 (guide page 225).  A=Add, D=Delete, U=Update.
			if(vaccine.ActionCode==VaccineAction.Add) {
				_seg.SetField(21,"A");
			}
			else if(vaccine.ActionCode==VaccineAction.Delete) {
				_seg.SetField(21,"D");
			}
			else if(vaccine.ActionCode==VaccineAction.Update) {
				_seg.SetField(21,"U");
			}
			//RXA-22 System Entry Date/Time.  Optional.
			//RXA-23 Administered Drug Strength.  Optional.
			//RXA-24 Administered Drug Strength Volume Units.  Optional.
			//RXA-25 Administered Barcode Identifier.  Optional.
			//RXA-26 Pharmacy Order Type.  Optional.
			_msg.Segments.Add(_seg);
		}
Пример #41
0
 ///<summary>Patient identification.</summary>
 private void PID(Patient pat)
 {
     seg=new SegmentHL7(SegmentName.PID);
     seg.SetField(0,"PID");
     seg.SetField(1,"1");
     seg.SetField(2,pat.ChartNumber);//Account number.  eCW requires this to be the same # as came in on PID.4.
     seg.SetField(3,pat.PatNum.ToString());//??what is this MRN?
     seg.SetField(5,pat.LName,pat.FName,pat.MiddleI);
     //we assume that dob is always valid because eCW should always pass us a dob.
     seg.SetField(7,pat.Birthdate.ToString("yyyyMMdd"));
     seg.SetField(8,ConvertGender(pat.Gender));
     seg.SetField(10,ConvertRace(pat.Race));
     seg.SetField(11,pat.Address,pat.Address2,pat.City,pat.State,pat.Zip);
     seg.SetField(13,ConvertPhone(pat.HmPhone));
     seg.SetField(14,ConvertPhone(pat.WkPhone));
     seg.SetField(16,ConvertMaritalStatus(pat.Position));
     seg.SetField(19,pat.SSN);
     msg.Segments.Add(seg);
 }
Пример #42
0
        ///<summary>Returns null if there is no HL7Def enabled or if there is no outbound DFT defined for the enabled HL7Def.</summary>
        public static MessageHL7 GenerateDFT(List <Procedure> listProcs, EventTypeHL7 eventType, Patient pat, Patient guar, long aptNum, string pdfDescription, string pdfDataString)
        {
            //In \\SERVERFILES\storage\OPEN DENTAL\Programmers Documents\Standards (X12, ADA, etc)\HL7\Version2.6\V26_CH02_Control_M4_JAN2007.doc
            //On page 28, there is a Message Construction Pseudocode as well as a flowchart which might help.
            MessageHL7 msgHl7 = new MessageHL7(MessageTypeHL7.DFT);
            HL7Def     hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find a DFT message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.DFT && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    //continue;
                    break;
                }
            }
            if (hl7DefMessage == null)           //DFT message type is not defined so do nothing and return
            {
                return(null);
            }
            if (PrefC.GetBool(PrefName.ShowFeaturePatientClone))
            {
                pat = Patients.GetOriginalPatientForClone(pat);
            }
            Provider       prov         = Providers.GetProv(Patients.GetProvNum(pat));
            Appointment    apt          = Appointments.GetOneApt(aptNum);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);

            for (int i = 0; i < hl7DefMessage.hl7DefSegments.Count; i++)
            {
                int repeatCount = 1;
                if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.FT1)
                {
                    repeatCount = listProcs.Count;
                }
                else if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                {
                    repeatCount = listPatPlans.Count;
                }
                //for example, countRepeat can be zero in the case where we are only sending a PDF of the TP to eCW, and no procs.
                //or the patient does not have any current insplans for IN1 segments
                for (int j = 0; j < repeatCount; j++)           //FT1 is optional and can repeat so add as many FT1's as procs in procList, IN1 is optional and can repeat as well, repeat for the number of patplans in patplanList
                {
                    if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.FT1 && listProcs.Count > j)
                    {
                        prov = Providers.GetProv(listProcs[j].ProvNum);
                    }
                    Procedure proc = null;
                    if (listProcs.Count > j)                   //procList could be an empty list
                    {
                        proc = listProcs[j];
                    }
                    PatPlan patPlanCur = null;
                    InsPlan insPlanCur = null;
                    InsSub  insSubCur  = null;
                    Carrier carrierCur = null;
                    Patient subscriber = null;
                    if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                    {
                        patPlanCur = listPatPlans[j];
                        insSubCur  = InsSubs.GetOne(patPlanCur.InsSubNum);
                        insPlanCur = InsPlans.RefreshOne(insSubCur.PlanNum);
                        carrierCur = Carriers.GetCarrier(insPlanCur.CarrierNum);
                        subscriber = Patients.GetPat(insSubCur.Subscriber);
                    }
                    SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
                    for (int f = 0; f < hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count; f++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].OrdinalPos, hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].FixedText);
                        }
                        else
                        {
                            string fieldValue = "";
                            if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                            {
                                fieldValue = FieldConstructor.GenerateFieldIN1(hl7Def, fieldName, j + 1, patPlanCur, insSubCur, insPlanCur, carrierCur, listPatPlans.Count, subscriber);
                            }
                            else
                            {
                                fieldValue = FieldConstructor.GenerateField(hl7Def, fieldName, MessageTypeHL7.DFT, pat, prov, proc, guar, apt, j + 1, eventType,
                                                                            pdfDescription, pdfDataString, MessageStructureHL7.DFT_P03, seg.Name);
                            }
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[f].OrdinalPos, fieldValue);
                        }
                    }
                    msgHl7.Segments.Add(seg);
                }
            }
            return(msgHl7);
        }
Пример #43
0
 ///<summary>PDF data segment.</summary>
 private void ZX1(string pdfDataAsBase64,string pdfDescription)
 {
     seg=new SegmentHL7(SegmentName.ZX1);
     seg.SetField(0,"ZX1");
     seg.SetField(1,"6");
     seg.SetField(2,"PDF");
     seg.SetField(3,"PATHOLOGY^Pathology Report^L");
     seg.SetField(4,pdfDescription);
     seg.SetField(5,pdfDataAsBase64);
     msg.Segments.Add(seg);
 }
Пример #44
0
        ///<summary>Observation/result segment.  Used to transmit observations related to the patient and visit.  Guide page 64.</summary>
        private void OBX()
        {
            List <EhrAptObs> listObservations = EhrAptObses.Refresh(_appt.AptNum);

            for (int i = 0; i < listObservations.Count; i++)
            {
                EhrAptObs obs = listObservations[i];
                _seg = new SegmentHL7(SegmentNameHL7.OBX);
                _seg.SetField(0, "OBX");
                _seg.SetField(1, (i + 1).ToString());             //OBX-1 Set ID - OBX.  Required (length 1..4).  Must start at 1 and increment.
                //OBX-2 Value Type.  Required (length 1..3).  Cardinality [1..1].  Identifies the structure of data in observation value OBX-5.  Values allowed: TS=Time Stamp (Date and/or Time),TX=Text,NM=Numeric,CWE=Coded with exceptions,XAD=Address.
                if (obs.ValType == EhrAptObsType.Coded)
                {
                    _seg.SetField(2, "CWE");
                }
                else if (obs.ValType == EhrAptObsType.DateAndTime)
                {
                    _seg.SetField(2, "TS");
                }
                else if (obs.ValType == EhrAptObsType.Numeric)
                {
                    _seg.SetField(2, "NM");
                }
                else                  //obs.ValType==EhrAptObsType.Text
                {
                    _seg.SetField(2, "TX");
                }
                //OBX-3 Observation Identifier.  Required (length up to 478).  Cardinality [1..1].  Value set is HL7 table named "Observation Identifier".  Type CE.  We use LOINC codes because the testing tool used LOINC codes and so do vaccines.
                string obsIdCode         = "";
                string obsIdCodeDescript = "";
                string obsIdCodeSystem   = "LN";
                if (obs.IdentifyingCode == EhrAptObsIdentifier.BodyTemp)
                {
                    obsIdCode         = "11289-6";
                    obsIdCodeDescript = "Body temperature:Temp:Enctrfrst:Patient:Qn:";
                }
                else if (obs.IdentifyingCode == EhrAptObsIdentifier.CheifComplaint)
                {
                    obsIdCode         = "8661-1";
                    obsIdCodeDescript = "Chief complaint:Find:Pt:Patient:Nom:Reported";
                }
                else if (obs.IdentifyingCode == EhrAptObsIdentifier.DateIllnessOrInjury)
                {
                    obsIdCode         = "11368-8";
                    obsIdCodeDescript = "Illness or injury onset date and time:TmStp:Pt:Patient:Qn:";
                }
                else if (obs.IdentifyingCode == EhrAptObsIdentifier.OxygenSaturation)
                {
                    obsIdCode         = "59408-5";
                    obsIdCodeDescript = "Oxygen saturation:MFr:Pt:BldA:Qn:Pulse oximetry";
                }
                else if (obs.IdentifyingCode == EhrAptObsIdentifier.PatientAge)
                {
                    obsIdCode         = "21612-7";
                    obsIdCodeDescript = "Age Time Patient Reported";
                }
                else if (obs.IdentifyingCode == EhrAptObsIdentifier.PrelimDiag)
                {
                    obsIdCode         = "44833-2";
                    obsIdCodeDescript = "Diagnosis.preliminary:Imp:Pt:Patient:Nom:";
                }
                else if (obs.IdentifyingCode == EhrAptObsIdentifier.TreatFacilityID)
                {
                    obsIdCode         = "SS001";
                    obsIdCodeDescript = "Treating Facility Identifier";
                    obsIdCodeSystem   = "PHINQUESTION";
                }
                else if (obs.IdentifyingCode == EhrAptObsIdentifier.TreatFacilityLocation)
                {
                    obsIdCode         = "SS002";
                    obsIdCodeDescript = "Treating Facility Location";
                    obsIdCodeSystem   = "PHINQUESTION";
                }
                else if (obs.IdentifyingCode == EhrAptObsIdentifier.TriageNote)
                {
                    obsIdCode         = "54094-8";
                    obsIdCodeDescript = "Triage note:Find:Pt:Emergency department:Doc:";
                }
                else if (obs.IdentifyingCode == EhrAptObsIdentifier.VisitType)
                {
                    obsIdCode         = "SS003";
                    obsIdCodeDescript = "Facility / Visit Type";
                    obsIdCodeSystem   = "PHINQUESTION";
                }
                WriteCE(3, obsIdCode, obsIdCodeDescript, obsIdCodeSystem);
                //OBX-4 Observation Sub-ID.  No longer used.
                //OBX-5 Observation Value.  Required if known (length 1..99999).  Value must match type in OBX-2.
                if (obs.ValType == EhrAptObsType.Address)
                {
                    WriteXAD(5, _sendingFacilityAddress1, _sendingFacilityAddress2, _sendingFacilityCity, _sendingFacilityState, _sendingFacilityZip);
                }
                else if (obs.ValType == EhrAptObsType.Coded)
                {
                    string codeDescript     = "";
                    string codeSystemAbbrev = "";
                    if (obs.ValCodeSystem.Trim().ToUpper() == "LOINC")
                    {
                        Loinc loincVal = Loincs.GetByCode(obs.ValReported);
                        codeDescript     = loincVal.NameShort;
                        codeSystemAbbrev = "LN";
                    }
                    else if (obs.ValCodeSystem.Trim().ToUpper() == "SNOMEDCT")
                    {
                        Snomed snomedVal = Snomeds.GetByCode(obs.ValReported);
                        codeDescript     = snomedVal.Description;
                        codeSystemAbbrev = "SCT";
                    }
                    else if (obs.ValCodeSystem.Trim().ToUpper() == "ICD9")
                    {
                        ICD9 icd9Val = ICD9s.GetByCode(obs.ValReported);
                        codeDescript     = icd9Val.Description;
                        codeSystemAbbrev = "I9";
                    }
                    else if (obs.ValCodeSystem.Trim().ToUpper() == "ICD10")
                    {
                        Icd10 icd10Val = Icd10s.GetByCode(obs.ValReported);
                        codeDescript     = icd10Val.Description;
                        codeSystemAbbrev = "I10";
                    }
                    WriteCE(5, obs.ValReported.Trim(), codeDescript, codeSystemAbbrev);
                }
                else if (obs.ValType == EhrAptObsType.DateAndTime)
                {
                    DateTime dateVal    = DateTime.Parse(obs.ValReported.Trim());
                    string   strDateOut = dateVal.ToString("yyyyMMdd");
                    //The testing tool threw errors when there were trailing zeros, even though technically valid.
                    if (dateVal.Second > 0)
                    {
                        strDateOut += dateVal.ToString("HHmmss");
                    }
                    else if (dateVal.Minute > 0)
                    {
                        strDateOut += dateVal.ToString("HHmm");
                    }
                    else if (dateVal.Hour > 0)
                    {
                        strDateOut += dateVal.ToString("HH");
                    }
                    _seg.SetField(5, strDateOut);
                }
                else if (obs.ValType == EhrAptObsType.Numeric)
                {
                    _seg.SetField(5, obs.ValReported.Trim());
                }
                else                   //obs.ValType==EhrAptObsType.Text
                {
                    _seg.SetField(5, obs.ValReported);
                }
                //OBX-6 Units.  Required if OBX-2 is NM=Numeric.  Cardinality [0..1].  Type CE.  The guide suggests value sets: Pulse Oximetry Unit, Temperature Unit, or Age Unit.  However, the testing tool used UCUM, so we will use UCUM.
                if (obs.ValType == EhrAptObsType.Numeric)
                {
                    if (String.IsNullOrEmpty(obs.UcumCode))                      //If units are required but known, we must send a null flavor.
                    {
                        WriteCE(6, "UNK", "", "NULLFL");
                    }
                    else
                    {
                        Ucum ucum = Ucums.GetByCode(obs.UcumCode);
                        WriteCE(6, ucum.UcumCode, ucum.Description, "UCUM");
                    }
                }
                //OBX-7 References Range.  No longer used.
                //OBX-8 Abnormal Flags.  No longer used.
                //OBX-9 Probability.  No longer used.
                //OBX-10 Nature of Abnormal Test.  No longer used.
                _seg.SetField(11, "F");               //OBX-11 Observation Result Status.  Required (length 1..1).  Expected value is "F".
                //OBX-12 Effective Date of Reference Range.  No longer used.
                //OBX-13 User Defined Access Checks.  No longer used.
                //OBX-14 Date/Time of the Observation.  Optional.
                //OBX-15 Producer's ID.  No longer used.
                //OBX-16 Responsible Observer.  No longer used.
                //OBX-17 Observation Method.  No longer used.
                //OBX-18 Equipment Instance Identifier.  No longer used.
                //OBX-19 Date/Time of the Analysis.  No longer used.
                _msg.Segments.Add(_seg);
            }
        }
Пример #45
0
        /*From	http://www.dt7.com/cdc/sampmsgs.html  example 1:
         * Vaccine Adverse Event Report (VAERS form) (unfortunately, does not seem adaptable to our situation)
         * MSH|^~\&||GA0000||VAERS PROCESSOR|20010331605||ORU^RO1|20010422GA03|T|2.3.1|||AL|
         * PID|||1234^^^^SR~1234-12^^^^LR~00725^^^^MR||Doe^John^Fitzgerald^JR^^^L||20001007|M||2106-3^White^HL70005|123 Peachtree St^APT 3B^Atlanta^GA^30210^^M^^GA067||(678) 555-1212^^PRN|
         * NK1|1|Jones^Jane^Lee^^RN|VAB^Vaccine administered by (Name)^HL70063|
         * NK1|2|Jones^Jane^Lee^^RN|FVP^Form completed by (Name)-Vaccine provider^HL70063|101 Main Street^^Atlanta^GA^38765^^O^^GA121||(404) 554-9097^^WPN|
         * ORC|CN|||||||||||1234567^Welby^Marcus^J^Jr^Dr.^MD^L|||||||||Peachtree Clinic|101 Main Street^^Atlanta^GA^38765^^O^^GA121|(404) 554-9097^^WPN|101 Main Street^^Atlanta^GA^38765^^O^^GA121|
         * OBR|1|||^CDC VAERS-1 (FDA) Report|||20010316|
         * OBX|1|NM|21612-7^Reported Patient Age^LN||05|mo^month^ANSI|
         * OBX|1|TS|30947-6^Date form completed^LN||20010316|
         * OBX|2|FT|30948-4^Vaccination adverse events and treatment, if any^LN|1|fever of 106F, with vomiting, seizures, persistent crying lasting over 3 hours, loss of appetite|
         * OBX|3|CE|30949-2^Vaccination adverse event outcome^LN|1|E^required emergency room/doctor visit^NIP005|
         * OBX|4|CE|30949-2^Vaccination adverse event outcome^LN|1|H^required hospitalization^NIP005|
         * OBX|5|NM|30950-0^Number of days hospitalized due to vaccination adverse event^LN|1|02|d^day^ANSI|
         * OBX|6|CE|30951-8^Patient recovered^LN||Y^Yes^ HL70239|
         * OBX|7|TS|30952-6^Date of vaccination^LN||20010216|
         * OBX|8|TS|30953-4^Adverse event onset date and time^LN||200102180900|
         * OBX|9|FT|30954-2^Relevant diagnostic tests/lab data^LN||Electrolytes, CBC, Blood culture|
         * OBR|2|||30955-9^All vaccines given on date listed in #10^LN|
         * OBX|1|CE30955-9&30956-7^Vaccine type^LN|1|08^HepB-Adolescent/pediatric^CVX|
         * OBX|2|CE|30955-9&30957-5^Manufacturer^LN|1|MSD^Merck^MVX|
         * OBX|3|ST|30955-9&30959-1^Lot number^LN|1|MRK12345|
         * OBX|4|CE|30955-9&30958-3^ Route^LN|1|IM^Intramuscular ^HL70162|
         * OBX|5|CE|30955-9&31034-2^Site^LN|1|LA^Left arm^ HL70163|
         * OBX|6|NM|30955-9&30960-9^Number of previous doses^LN|1|01I
         * OBX|7|CE|CE|30955-9&30956-7^Vaccine type^LN|2|50^DTaP-Hib^CVX|
         * OBX|8|CE|30955-9&30957-5^ Manufacturer^LN|2|WAL^Wyeth_Ayerst^MVX|
         * OBX|9|ST|30955-9&30959-1^Lot number^LN|2|W46932777|
         * OBX|10|CE|30955-9&30958-3^ Route^LN|2|IM^Intramuscular^HL70162|
         *
         */


        /*This is the example that we are using for incorporating lab results in our other test.
         * It is simpler than the above examples.  We might want to use it instead.
         * MSH|^~\&|KAM|DGI|Y|OU|20100920093000||ORU^R01^ORU_R01|20100920093000|P|2.3.1
         * PID||405979410 |405979410^^^&2.16.840.1.113883.19.3.2.1&ISO^MR||Lewis^Frank ||19500101|M||2106-3^White^HL70005|622 Chestnut^^Springfield^Tennessee^37026^^M||^^^^^615^3826396|||||405979410 ||||N^Not Hispanic or Latino^HL70189
         * OBR|1|OrderNum-1001|FillOrder-1001|24331-1^Lipid Panel^LN||20100920083000|20100920083000|20100920083000|||||Hemolyzed ||| ProviderIDNum-100^Crow^Tom^Black^III^Dr.||||Aloha Laboratories 575 Luau Street Honolulu Hawaii 96813 ||||CH|F|
         * OBX|1|NM|14647-2^Total cholesterol^LN |134465|162|mg/dl |<200| N|||F|||20100920083000
         * OBX|2|NM|14646-4^HDL cholesterol^LN|333123|43|mg/dl|>=40| N|||F|||20100920083000
         * OBX|3|NM|2089-1^LDL cholesterol^LN|333123|84|mg/dl|<100| N|||F|||20100920083000
         * OBX|4|NM|14927-8^Triglycerides^LN|333123|127|mg/dl|<150| N|||F|||20100920083000*/

        /*This is example #5 from the mu site.  Hepatitis C is a legitimate reportable syndrome which would be reported to public health
         * MSH|^~\&|EHR Application^2.16.840.1.113883.3.72.7.1^HL7|EHR Facility^2.16.840.1.113883.3.72.7.2^HL7|PH Application^2.16.840.1.113883.3.72.7.3^HL7|PH Facility^2.16.840.1.113883.3.72.7.4^HL7|20110316102334||ORU^R01^ORU_R01|NIST-110316102333943|P|2.5.1|||||||||PHLabReport-Ack^^2.16.840.1.114222.4.10.3^ISO
         * SFT|NIST Lab, Inc.|3.6.23|A-1 Lab System|6742873-12||20080303
         * PID|||686774009^^^MPI&2.16.840.1.113883.19.3.2.1&ISO^MR||Takamura^Michael||19820815|M||2028-9^Asian^HL70005|3567 Maple Street^^Oakland^CA^94605^USA^M||^PRN^^^^510^6658876|||||||||N^Not Hispanic or Latino^HL70189
         * OBR|1||7564832^Lab^2.16.840.1.113883.19.3.1.6^ISO|10676-5^Hepatitis C Virus RNA^LN^1198112^Hepatitis C Test^99USI|||201007281400||||||Nausea, vomiting, abdominal pain|||1234^Admit^Alan^^^^^^ABC Medical Center&2.16.840.1.113883.19.4.6&ISO||||||201007301500|||F||||||787.01^Nausea and vomiting^I9CDX~789.0^Abdominal pain^I9CDX
         * OBX|1|NM|10676-5^Hepatitis C Virus RNA^LN|1|850000|iU/mL^international units per mililiter^UCUM|High Viral Load > or = 850000iU/mL|H|||F|||201007281400|||||200807301500||||Lab^L^^^^CLIA&2.16.840.1.113883.19.4.6&ISO^XX^^^1236|3434 Industrial Lane^^Ann Arbor^MI^48103^^B
         * SPM||||122555007^Venous blood specimen^SCT^BLDV^Blood venous^HL70487^20080131^2.5.1
         */


        private void OBR(LabPanel panel, DateTime datetime)
        {
            seg = new SegmentHL7(SegmentName.OBR);
            seg.SetField(0, "OBR");
            seg.SetField(1, "1");
            seg.SetField(2, "OrderNum-1001");
            seg.SetField(3, "FillOrder-1001");
            seg.SetField(4, panel.ServiceId, panel.ServiceName, "LN");         //eg 10676-5, Hepatitis C Virus RNA
            seg.SetField(6, datetime.ToString("yyyyMMddhhmmss"));
            seg.SetField(7, datetime.ToString("yyyyMMddhhmmss"));
            seg.SetField(8, datetime.ToString("yyyyMMddhhmmss"));
            seg.SetField(13, panel.SpecimenCondition);
            seg.SetField(15, panel.SpecimenSource);
            seg.SetField(20, panel.LabNameAddress);
            seg.SetField(24, "CH");
            seg.SetField(25, "F");
            msg.Segments.Add(seg);
        }
Пример #46
0
 ///<summary>Patient Visit segment.  Used by Registration/Patient Administration applications to communicate information on a visit-specific basis.  Guide page 51.</summary>
 private void PV1()
 {
     _seg = new SegmentHL7(SegmentNameHL7.PV1);
     _seg.SetField(0, "PV1");
     _seg.SetField(1, "1");           //PV1-1 SET ID - PV1.  Required if known (length 1..4).  Must be set to "1".
     //PV1-2 Patient Class.  Optional.
     //PV1-3 Assigned Patient Location.  Optional.
     //PV1-4 Admission Type.  Optional.
     //PV1-5 Pre-admit Number.  No longer used.
     //PV1-6 Prior Patient Location.  No longer used.
     //PV1-7 Attending Doctor.  No longer used.
     //PV1-8 Referring Doctor.  No longer used.
     //PV1-9 Consulting Doctor.  No longer used.
     //PV1-10 Hospital Service.  Optional.
     //PV1-11 Temporary Location.  No longer used.
     //PV1-12 Preadmit Test Indicator.  No longer used.
     //PV1-13 Re-admission Indicator.  No longer used.
     //PV1-14 Admit Source.  Optional.
     //PV1-15 Ambulatory Status.  Optional.
     //PV1-16 VIP Indicator.  No longer used.
     //PV1-17 Admitting Doctor.  No longer used.
     //PV1-18 Patient Type.  No longer used.
     //PV1-19 Visit Number.  Required (length up to 478).  Cardinality [1..1].
     _seg.SetField(19,
                   _appt.AptNum.ToString(), //PV1-19.1 ID Number.  Required (length 1..15).  Unique identifier for patient visit.
                   "",                      //PV1-19.2 Check Digit.  No longer used.
                   "",                      //PV1-19.3 Check Digit Scheme.  No longer used.
                   "",                      //PV1-19.4 Assigning Authority.  Optional.
                   "VN"                     //PV1-19.5 Identifier Type Code.  Required (length 1..5).  Identifier type corresponding to the ID number from PV1-19.1.  VN=Visit Number.
                                            //PV1-19.6 Assigning Facility.  Optional.
                                            //PV1-19.7 Effective Date.  No longer used.
                                            //PV1-19.8 Expiration Date.  No longer used.
                                            //PV1-19.9 Assigning Jurisdiction.  No longer used.
                                            //PV1-19.10 Assigning Facility.  No longer used.
                   );
     //PV1-20 Financial Class.  No longer used.
     //PV1-21 Charge Price Indicator.  No longer used.
     //PV1-22 Courtesy Code.  No longer used.
     //PV1-23 Credit Rating.  No longer used.
     //PV1-24 Contract Code.  No longer used.
     //PV1-25 Contract Effective Date.  No longer used.
     //PV1-26 Contract Amount.  No longer used.
     //PV1-27 Contract Period.  No longer used.
     //PV1-28 Interest Code.  No longer used.
     //PV1-29 Transfer to Bad Debt Code.  No longer used.
     //PV1-30 Transfer to Bad Debt Date.  No longer used.
     //PV1-31 Bad Debt Agency Code.  No longer used.
     //PV1-32 Bad Debt Transfer Amount.  No longer used.
     //PV1-33 Bad Debt Recovery Amount.  No longer used.
     //PV1-34 Delete Account Indicator.  No longer used.
     //PV1-35 Delete Account Date.  No longer used.
     //PV1-36 Discharge Disposition.  Required if known (length 1..3).  Cardinality [0..1].  Discharge Disposition HL7 table.
     //PV1-37 Discharged to Location.  No longer used.
     //PV1-38 Diet Type.  No longer used.
     //PV1-39 Servicing Facility.  No longer used.
     //PV1-40 Bed Status.  No longer used.
     //PV1-41 Account Status.  No longer used.
     //PV1-42 Pending Location.  No longer used.
     //PV1-43 Prior Temporary Location.  No longer used.
     _seg.SetField(44, _appt.AptDateTime.ToString("yyyyMMddhhmm"));           //PV1-44 Admit Date/Time.  Required (length 12..26).  Date and time of the patient presentation.
     //PV1-45 Discharge Date/Time.  Optional.
     //PV1-46 Current Patient Balance.  No longer used.
     //PV1-47 Total Charges.  No longer used.
     //PV1-48 Total Adjustments.  No longer used.
     //PV1-49 Total Payments.  No longer used.
     //PV1-50 Alternate Visit ID.  No longer used.
     //PV1-51 Visit Indicator.  No longer used.
     //PV1-52 Other Healthcare Provider.  No longer used.
     _msg.Segments.Add(_seg);
 }
Пример #47
0
        //OBR|1|||30955-9^Vaccine Given^LN|
        //OBX|1|CE30955-9&30956-7^Vaccine type^LN|1|08^HepB-Adolescent/pediatric^CVX|

        /// <summary>idx passed in will be zero-based. Will be converted to 1-based.</summary>
        private void OBX(LabResult labresult, int idx)
        {
            seg = new SegmentHL7(SegmentName.OBX);
            seg.SetField(0, "OBX");
            seg.SetField(1, (idx + 1).ToString());
            seg.SetField(2, "NM");                                               //ValueType. NM=numeric, referring to the value that will follow in OBX-5
            seg.SetField(3, labresult.TestID, labresult.TestName, "LN");         //TestPerformed  ID^text^codingSystem.  eg. 10676-5^Hepatitis C Virus RNA^LN
            seg.SetField(4, "1");                                                //?
            seg.SetField(5, labresult.ObsValue);                                 //Value. Type based on OBX-2.  eg. 850000.
            seg.SetField(6, labresult.ObsUnits);                                 //Units. Example iU/mL^international units per mililiter
            seg.SetField(7, labresult.ObsRange);                                 //Range. Example High Viral Load >= 850000iU/mL
            seg.SetField(8, "N");                                                //?
            seg.SetField(11, "F");                                               //OBX-11 is required.  F means final.
            seg.SetField(14, labresult.DateTimeTest.ToString("yyyyMMddhhmmss")); //OBX-14 datetime
            msg.Segments.Add(seg);
        }
Пример #48
0
        ///<summary>Returns null if there is no HL7Def enabled or if there is no outbound ADT defined for the enabled HL7Def.</summary>
        public static MessageHL7 GenerateADT(Patient pat, Patient guar, EventTypeHL7 eventType)
        {
            HL7Def hl7Def = HL7Defs.GetOneDeepEnabled();

            if (hl7Def == null)
            {
                return(null);
            }
            //find an outbound ADT message in the def
            HL7DefMessage hl7DefMessage = null;

            for (int i = 0; i < hl7Def.hl7DefMessages.Count; i++)
            {
                if (hl7Def.hl7DefMessages[i].MessageType == MessageTypeHL7.ADT && hl7Def.hl7DefMessages[i].InOrOut == InOutHL7.Outgoing)
                {
                    hl7DefMessage = hl7Def.hl7DefMessages[i];
                    //continue;
                    break;
                }
            }
            if (hl7DefMessage == null)           //ADT message type is not defined so do nothing and return
            {
                return(null);
            }
            if (PrefC.GetBool(PrefName.ShowFeaturePatientClone))
            {
                pat = Patients.GetOriginalPatientForClone(pat);
            }
            MessageHL7     messageHL7   = new MessageHL7(MessageTypeHL7.ADT);
            Provider       prov         = Providers.GetProv(Patients.GetProvNum(pat));
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);

            for (int i = 0; i < hl7DefMessage.hl7DefSegments.Count; i++)
            {
                int countRepeat = 1;
                //IN1 segment can repeat, get the number of current insurance plans attached to the patient
                if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                {
                    countRepeat = listPatPlans.Count;
                }
                //countRepeat is usually 1, but for repeatable/optional fields, it may be 0 or greater than 1
                //for example, countRepeat can be zero if the patient does not have any current insplans, in which case no IN1 segments will be included
                for (int j = 0; j < countRepeat; j++)           //IN1 is optional and can repeat so add as many as listPatplans
                {
                    PatPlan patplanCur = null;
                    InsPlan insplanCur = null;
                    InsSub  inssubCur  = null;
                    Carrier carrierCur = null;
                    Patient patSub     = null;
                    if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)                   //index repeat is guaranteed to be less than listPatplans.Count
                    {
                        patplanCur = listPatPlans[j];
                        inssubCur  = InsSubs.GetOne(patplanCur.InsSubNum);
                        insplanCur = InsPlans.RefreshOne(inssubCur.PlanNum);
                        carrierCur = Carriers.GetCarrier(insplanCur.CarrierNum);
                        if (pat.PatNum == inssubCur.Subscriber)
                        {
                            patSub = pat.Copy();
                        }
                        else
                        {
                            patSub = Patients.GetPat(inssubCur.Subscriber);
                        }
                    }
                    SegmentHL7 seg = new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
                    seg.SetField(0, hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
                    for (int k = 0; k < hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count; k++)
                    {
                        string fieldName = hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FieldName;
                        if (fieldName == "")                       //If fixed text instead of field name just add text to segment
                        {
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FixedText);
                        }
                        else
                        {
                            string fieldValue = "";
                            if (hl7DefMessage.hl7DefSegments[i].SegmentName == SegmentNameHL7.IN1)
                            {
                                fieldValue = FieldConstructor.GenerateFieldIN1(hl7Def, fieldName, j + 1, patplanCur, inssubCur, insplanCur, carrierCur, listPatPlans.Count, patSub);
                            }
                            else
                            {
                                fieldValue = FieldConstructor.GenerateFieldADT(hl7Def, fieldName, pat, prov, guar, j + 1, eventType, seg.Name);
                            }
                            seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos, fieldValue);
                        }
                    }
                    messageHL7.Segments.Add(seg);
                }
            }
            return(messageHL7);
        }
Пример #49
0
		///<summary>Returns null if there is no HL7Def enabled or if there is no outbound ADT defined for the enabled HL7Def.</summary>
		public static MessageHL7 GenerateADT(Patient pat,Patient guar,EventTypeHL7 eventType) {
			HL7Def hl7Def=HL7Defs.GetOneDeepEnabled();
			if(hl7Def==null) {
				return null;
			}
			//find an outbound ADT message in the def
			HL7DefMessage hl7DefMessage=null;
			for(int i=0;i<hl7Def.hl7DefMessages.Count;i++) {
				if(hl7Def.hl7DefMessages[i].MessageType==MessageTypeHL7.ADT && hl7Def.hl7DefMessages[i].InOrOut==InOutHL7.Outgoing) {
					hl7DefMessage=hl7Def.hl7DefMessages[i];
					//continue;
					break;
				}
			}
			if(hl7DefMessage==null) {//ADT message type is not defined so do nothing and return
				return null;
			}
			if(PrefC.GetBool(PrefName.ShowFeaturePatientClone)) {
				Patient patClone;
				Patient patNonClone;
				List<Patient> listAmbiguousMatches;
				Patients.GetCloneAndNonClone(pat,out patClone,out patNonClone,out listAmbiguousMatches);
				if(patNonClone!=null) {
					pat=patNonClone;
				}
			}
			MessageHL7 messageHL7=new MessageHL7(MessageTypeHL7.ADT);
			Provider prov=Providers.GetProv(Patients.GetProvNum(pat));
			List<PatPlan> listPatPlans=PatPlans.Refresh(pat.PatNum);
			for(int i=0;i<hl7DefMessage.hl7DefSegments.Count;i++) {
				int countRepeat=1;
				//IN1 segment can repeat, get the number of current insurance plans attached to the patient
				if(hl7DefMessage.hl7DefSegments[i].SegmentName==SegmentNameHL7.IN1) {
					countRepeat=listPatPlans.Count;
				}
				//countRepeat is usually 1, but for repeatable/optional fields, it may be 0 or greater than 1
				//for example, countRepeat can be zero if the patient does not have any current insplans, in which case no IN1 segments will be included
				for(int j=0;j<countRepeat;j++) {//IN1 is optional and can repeat so add as many as listPatplans
					PatPlan patplanCur=null;
					InsPlan insplanCur=null;
					InsSub inssubCur=null;
					Carrier carrierCur=null;
					Patient patSub=null;
					if(hl7DefMessage.hl7DefSegments[i].SegmentName==SegmentNameHL7.IN1) {//index repeat is guaranteed to be less than listPatplans.Count
						patplanCur=listPatPlans[j];
						inssubCur=InsSubs.GetOne(patplanCur.InsSubNum);
						insplanCur=InsPlans.RefreshOne(inssubCur.PlanNum);
						carrierCur=Carriers.GetCarrier(insplanCur.CarrierNum);
						if(pat.PatNum==inssubCur.Subscriber) {
							patSub=pat.Copy();
						}
						else {
							patSub=Patients.GetPat(inssubCur.Subscriber);
						}
					}
					SegmentHL7 seg=new SegmentHL7(hl7DefMessage.hl7DefSegments[i].SegmentName);
					seg.SetField(0,hl7DefMessage.hl7DefSegments[i].SegmentName.ToString());
					for(int k=0;k<hl7DefMessage.hl7DefSegments[i].hl7DefFields.Count;k++) {
						string fieldName=hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FieldName;
						if(fieldName=="") {//If fixed text instead of field name just add text to segment
							seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos,hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].FixedText);
						}
						else {
							string fieldValue="";
							if(hl7DefMessage.hl7DefSegments[i].SegmentName==SegmentNameHL7.IN1) {
								fieldValue=FieldConstructor.GenerateFieldIN1(hl7Def,fieldName,j+1,patplanCur,inssubCur,insplanCur,carrierCur,listPatPlans.Count,patSub);
							}
							else {
								fieldValue=FieldConstructor.GenerateFieldADT(hl7Def,fieldName,pat,prov,guar,j+1,eventType,seg.Name);
							}
							seg.SetField(hl7DefMessage.hl7DefSegments[i].hl7DefFields[k].OrdinalPos,fieldValue);
						}
					}
					messageHL7.Segments.Add(seg);
				}
			}
			return messageHL7;
		}