///<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); }
///<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); }
///<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); }