///<summary>Sets values on _medLabCur based on the PID segment fields. Also sets medlab.OriginalPIDSegment to the full PID segment.</summary> public static void ProcessPID(HL7DefSegment segDef,SegmentHL7 pidSeg) { _medLabCur.OriginalPIDSegment=pidSeg.ToString(); for(int i=0;i<segDef.hl7DefFields.Count;i++) { HL7DefField fieldDefCur=segDef.hl7DefFields[i]; switch(fieldDefCur.FieldName) { case "accountNum": _medLabCur.PatAccountNum=pidSeg.GetFieldComponent(fieldDefCur.OrdinalPos); string fastingStr=pidSeg.GetFieldComponent(fieldDefCur.OrdinalPos,6); //if the component is blank or has a value other than "Y" or "N", the PatFasting field will be 0 - Unknown if(fastingStr.Length>0) { fastingStr=fastingStr.ToLower().Substring(0,1); if(fastingStr=="y") { _medLabCur.PatFasting=YN.Yes; } else if(fastingStr=="n") { _medLabCur.PatFasting=YN.No; } } continue; case "altPatID": _medLabCur.PatIDAlt=pidSeg.GetFieldComponent(fieldDefCur.OrdinalPos); continue; case "labPatID": _medLabCur.PatIDLab=pidSeg.GetFieldComponent(fieldDefCur.OrdinalPos); continue; case "pat.nameLFM": //not currently using this to update any db fields, only used to validate the correct patient was selected continue; case "pat.PatNum": if(_patCur!=null) { //If a patient was not located, the MedLab object will have a 0 for PatNum. //We will be able to generate a list of all 'unattached' MedLab objects so the user can manually select the correct patient. _medLabCur.PatNum=_patCur.PatNum; } continue; case "patBirthdateAge": //the birthday field for MedLab is birthdate^age in years^age months^age days. //The year component is left padded with 0's to three digits, the month and day components are left padded with 0's to two digits. //If the year, age, or month components don't exist or are blank, the default will be to //Example: 19811213^033^02^19 FieldHL7 fieldCur=pidSeg.GetField(fieldDefCur.OrdinalPos); if(fieldCur==null || fieldCur.Components.Count<4) {//if there aren't even 4 components (3 ^'s) in the field, don't set the age continue; } _medLabCur.PatAge=pidSeg.GetFieldComponent(fieldDefCur.OrdinalPos,1).PadLeft(3,'0')+"/" +pidSeg.GetFieldComponent(fieldDefCur.OrdinalPos,2).PadLeft(2,'0')+"/" +pidSeg.GetFieldComponent(fieldDefCur.OrdinalPos,3).PadLeft(2,'0'); continue; default: continue; } } return; }