public static void LoadAllPatientFromSchedular() { string fullpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\InjectionSoftware\" + @"\Schedular"; if (!Directory.Exists(fullpath)) { Directory.CreateDirectory(fullpath); } foreach (var file in Directory.EnumerateFiles(fullpath, "*.hl7")) { try { string text = System.IO.File.ReadAllText(file); Hl7file ff = Hl7file.load(text); Patient patient = new Patient(ff); Console.Out.WriteLine("[PatientManager] Loading patient information from HL7 file with patientID:" + patient.PatientID); if (patient.PatientID == "") { Console.WriteLine("[PatientManager.LoadAllPatient()] " + file + " path contain corrupted information, the patient information has failed to load"); continue; } ModPatient(patient); } catch (System.Exception e) { Console.Error.WriteLine(e); } } InjectionsManager.recreateObservableList(); }
public Patient(Hl7file hl7File) { try { PatientID = hl7File.getSegment("PID").getString(3).Split('^')[0]; PatientSurname = hl7File.getSegment("PID").getString(5).Split('^')[0]; if (hl7File.getSegment("PID").getString(5).Split('^').Length > 1) { PatientLastname = hl7File.getSegment("PID").getString(5).Split('^')[1]; } else { PatientLastname = ""; } string rawDateOfBirth = hl7File.getSegment("PID").getString(7); DateOfBirth = DOBconverter.hl7DOBtoBarcodeDOB(rawDateOfBirth); IsMale = hl7File.getSegment("PID").getString(8) == "M" ? true : false; PhoneNumber = hl7File.getSegment("PID").getString(13); IsInpatient = hl7File.getSegment("PV1").getString(2) == "I" ? true : false; Referral = hl7File.getSegment("PV1").getString(7).Replace('^', ' '); UniqueExamIdentifier = hl7File.getSegment("OBR").getString(2); ExamCode = hl7File.getSegment("OBR").getString(3).Split('-')[0]; ExamName = hl7File.getSegment("OBR").getString(4); } catch (System.Exception e) { Console.Error.WriteLine(e); } }