protected void Page_Load(object sender, EventArgs e) { double bmi = 0.0; string bmiZ; decimal diastolic = 0; decimal systolic = 0; string bmiAnalysis = ""; string bpAnalysis = ""; var patientVitals = new PatientVitalsManager(); PatientVital patientTriage; if (Request.QueryString["visitId"] != null) { Session["ExistingRecordPatientMasterVisitID"] = Request.QueryString["visitId"].ToString(); patientTriage = patientVitals.GetByPatientVisitId(Convert.ToInt32(Session["ExistingRecordPatientMasterVisitID"])); } else { Session["ExistingRecordPatientMasterVisitID"] = "0"; patientTriage = patientVitals.GetByPatientId(PatientId); } PatientLookupManager pMgr = new PatientLookupManager(); //PatientVital patientTriage = patientVitals.GetByPatientId(PatientId); PatientLookup thisPatient = pMgr.GetPatientDetailSummary(PatientId); int age = Convert.ToInt32(HttpContext.Current.Session["Age"]); DateTime DoB = Convert.ToDateTime(thisPatient.DateOfBirth); var patientAge = PatientManager.CalculateYourAge(DoB); lblAge.Text = "<strong><i>" + patientAge.Replace("Age:", "") + "</i></strong>"; string notTaken = "<span class='label label-danger'>Not Taken!</span>"; if (patientTriage != null) { lblDatetaken.Text = Convert.ToDateTime(patientTriage.VisitDate).ToString("dd-MMM-yyyy"); bmi = Convert.ToDouble(patientTriage.BMI); bmiZ = Convert.ToString(patientTriage.BMIZ); diastolic = Convert.ToDecimal(patientTriage.Bpdiastolic); systolic = Convert.ToDecimal(patientTriage.BpSystolic); bpDiastolic = Convert.ToInt32(diastolic); bpSystloic = Convert.ToInt32(systolic); bgSystolicT.Text = bpSystloic.ToString() + " (Systolic)"; pgDiastolicT.Text = bpDiastolic.ToString() + " (Diastolic)"; if (patientTriage.Temperature > 0) { if (patientTriage.Temperature > 40) { lblTemperature.Text = "<span class='label label-danger'>" + Convert.ToString(patientTriage.Temperature) + "°C | Possible Hyperpyrexia"; } else if (Convert.ToDouble(patientTriage.Temperature) >= 36.0 && Convert.ToDouble(patientTriage.Temperature) <= 38) { lblTemperature.Text = "<span class='label label-success'>" + Convert.ToString(patientTriage.Temperature) + "°C | Normal"; } else if (Convert.ToDouble(patientTriage.Temperature) > 38 && Convert.ToDouble(patientTriage.Temperature) <= 40.0) { lblTemperature.Text = "<span class='label label-danger'>" + Convert.ToString(patientTriage.Temperature) + "°C | Possible Hyperpyrexia"; } else if (patientTriage.Temperature < 32) { lblTemperature.Text = "<span class='label label-danger'>" + Convert.ToString(patientTriage.Temperature) + "°C | Medical Emergency"; } else if (patientTriage.Temperature >= 32 && patientTriage.Temperature < 36) { lblTemperature.Text = "<span class='label label-danger'>" + Convert.ToString(patientTriage.Temperature) + "°C | Hypothermia "; } } else { lblTemperature.Text = "<span class='label label-danger'>" + Convert.ToString(patientTriage.Temperature) + "NO Temperature Readings "; } if (diastolic < 1 & systolic < 1) { lblbloodpressure.Text = "<span class='label label-danger'> NOT TAKEN </span>"; } else { if (systolic < 120 & diastolic < 80) { bpAnalysis = "<span class='label label-success'>" + Convert.ToString(systolic) + "/" + Convert.ToString(diastolic) + "mm[Hg] | Normal </span>"; } else if (systolic >= 120 | systolic < 129 & diastolic < 80) { bpAnalysis = "<span class='label label-success'>" + Convert.ToString(systolic) + "/" + Convert.ToString(diastolic) + "mm[Hg] | Elavated </span>"; } else if (systolic > 130 || systolic < 139 && diastolic > 80 || diastolic < 89) { bpAnalysis = "<span class='label label-warning'> " + Convert.ToString(systolic) + "/" + Convert.ToString(diastolic) + "mm[Hg] | HYPERTENSION STAGE 1</span>"; } else if (systolic > 140 && diastolic > 90) { bpAnalysis = "<span class='label label-danger'> " + Convert.ToString(systolic) + "/" + Convert.ToString(diastolic) + " |mm[Hg] | HYPERTENSION STAGE 2</span>"; } else if (systolic > 180 && diastolic > 120) { bpAnalysis = "<span class='label label-warning'> " + Convert.ToString(systolic) + "/" + Convert.ToString(diastolic) + " |mm[Hg] | HYPERTENSIVE CRISIS </span>"; } lblbloodpressure.Text = bpAnalysis; } if (age > 15 & patientTriage.Muac > 0) { lblMuac.Text = Convert.ToString(patientTriage.Muac) + "cms"; lblMuac.Text = "<span class='label label-warning'> " + Convert.ToString(patientTriage.Muac) + " | CMs " + "</span>"; } else { lblMuac.Text = "<span class='label label-danger'> 0 | Cms </span>"; } if (age > 15) { if (bmi < 18.5) { bmiAnalysis = "<span class='label label-danger'>" + Convert.ToString(patientTriage.BMI) + "Kg/M2" + " | Under weight</span>"; } else if (bmi >= 18.5 & bmi < 25.0) { bmiAnalysis = "<span class='label label-success'> " + Convert.ToString(patientTriage.BMI) + "Kg/M2" + " | Normal weight</span>"; } else if (bmi >= 25 & bmi < 30.0) { bmiAnalysis = "<span class='label label-warning'> " + Convert.ToString(patientTriage.BMI) + "Kg/M2" + " | Over weight<span>"; } else { bmiAnalysis = "<span class='label label-danger'> " + Convert.ToString(patientTriage.BMI) + "Kg/M2" + " | Obese<span>"; } } else { bmiAnalysis = bmiZ; } lblBMI.Text = bmiAnalysis; if ((int)patientTriage.HeartRate == 0) { lblPulseRate.Text = notTaken; } else { lblPulseRate.Text = "<span class='label label-info'>" + patientTriage.HeartRate + " beats/min</span>"; } if ((int)patientTriage.SpO2 == 0) { lblOxygenSaturation.Text = notTaken; } else { lblOxygenSaturation.Text = "<span class='label label-info'>" + patientTriage.SpO2 + " %</span>"; } if ((int)patientTriage.RespiratoryRate == 0) { lblRespiratoryRate.Text = notTaken; } else { lblRespiratoryRate.Text = "<span class='label label-info'>" + patientTriage.RespiratoryRate + " breaths/min</span>"; } } else { lblTemperature.Text = notTaken; lblbloodpressure.Text = notTaken; lblBMI.Text = notTaken; lblPulseRate.Text = notTaken; lblOxygenSaturation.Text = notTaken; lblRespiratoryRate.Text = notTaken; } var patientAppointment = new PatientAppointmentManager(); var pa = patientAppointment.GetByPatientId(PatientId); if (pa != null) { foreach (var item in pa) { lblappointmentDate.Text = "<span class='pull-right'>" + Convert.ToDateTime(item.AppointmentDate).ToString("dd-MMM-yyyy") + "</span>"; lblAppointmentReason.Text = "<span class='pull-right'>" + LookupLogic.GetLookupNameById(item.ReasonId) + "</span>"; lblappointmentStatus.Text = "<span class='pull-right'>" + LookupLogic.GetLookupNameById(item.StatusId) + "</span>"; lblcareStatus.Text = "<span class='pull-right'>" + LookupLogic.GetLookupNameById(item.DifferentiatedCareId) + "</span>"; } } }
public string Save(PatientRegistrationDTO registration) { try { LookupLogic lookupLogic = new LookupLogic(); PatientLookupManager patientLookup = new PatientLookupManager(); PatientLookup patient = new PatientLookup(); PatientRegistrationValidation registrationValidation = new PatientRegistrationValidation(); //Validate DTO string results = registrationValidation.ValidateDTO(registration); if (!String.IsNullOrWhiteSpace(results)) { throw new Exception(results); } int interopUserId = InteropUser.UserId; //Get FacilityId int facilityId = Convert.ToInt32(registration.MESSAGE_HEADER.SENDING_FACILITY); //Get Gender string gender = registration.PATIENT_IDENTIFICATION.SEX == "F" ? "Female" : "Male"; //IQCare Sex int sex = lookupLogic.GetItemIdByGroupAndItemName("Gender", gender)[0].ItemId; //Assume this is a new patient int patientType = lookupLogic.GetItemIdByGroupAndItemName("PatientType", registration.PATIENT_VISIT.PATIENT_TYPE)[0].ItemId; //Get Enrollment Id Type int visitType = lookupLogic.GetItemIdByGroupAndItemName("VisitType", "Enrollment")[0].ItemId; //Get DOB DateTime DOB = DateTime.ParseExact(registration.PATIENT_IDENTIFICATION.DATE_OF_BIRTH, "yyyyMMdd", null); bool DOB_Precision = true; switch (registration.PATIENT_IDENTIFICATION.DATE_OF_BIRTH_PRECISION) { case "ESTIMATED": DOB_Precision = false; break; case "EXACT": DOB_Precision = true; break; default: DOB_Precision = true; break; } //Get Enrollment Date DateTime dateOfEnrollment = DateTime.ParseExact(registration.PATIENT_VISIT.HIV_CARE_ENROLLMENT_DATE, "yyyyMMdd", null); //Get Patient Names string firstName = registration.PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME; string middleName = registration.PATIENT_IDENTIFICATION.PATIENT_NAME.MIDDLE_NAME; string lastName = registration.PATIENT_IDENTIFICATION.PATIENT_NAME.LAST_NAME; //Get gods number string godsNumber = registration.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.ID; //get marital status string maritalStatusString = String.Empty; int maritalStatusId = 0; switch (registration.PATIENT_IDENTIFICATION.MARITAL_STATUS) { case "S": maritalStatusString = "Single"; break; case "W": maritalStatusString = "Widowed"; break; case "D": maritalStatusString = "Divorced"; break; case "MP": maritalStatusString = "Married Polygamous"; break; case "C": maritalStatusString = "Cohabiting"; break; case "MM": maritalStatusString = "Married Monogamous"; break; default: maritalStatusString = "Unknown"; break; } maritalStatusId = lookupLogic.GetItemIdByGroupAndItemName("MaritalStatus", maritalStatusString)[0].ItemId; //Get patient Address string village = String.Empty; string ward = String.Empty; string sub_county = String.Empty; string county = String.Empty; string nearestLandMark = String.Empty; string postalAdress = String.Empty; string phoneNumber = String.Empty; string deathDate = String.Empty; var patient_address = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS; if (patient_address != null) { var physicalAddress = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS; if (physicalAddress != null) { village = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.VILLAGE; ward = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.WARD; sub_county = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.SUB_COUNTY; county = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.COUNTY; nearestLandMark = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.PHYSICAL_ADDRESS.NEAREST_LANDMARK; } postalAdress = registration.PATIENT_IDENTIFICATION.PATIENT_ADDRESS.POSTAL_ADDRESS; } //Lookup Ward, sub_county_county int wardId = 0; int subCountyId = 0; int countyId = 0; var countyDetails = lookupLogic.GetCountyDetailsByWardName(ward); if (countyDetails != null) { wardId = countyDetails.WardId; subCountyId = countyDetails.SubcountyId; countyId = countyDetails.CountyId; } //Get Phone Number phoneNumber = registration.PATIENT_IDENTIFICATION.PHONE_NUMBER; deathDate = registration.PATIENT_IDENTIFICATION.DEATH_DATE; DateTime?DateOfDeath = null; if (!string.IsNullOrWhiteSpace(deathDate)) { DateOfDeath = DateTime.ParseExact(deathDate, "yyyyMMdd", null); } //GET NEXT OF KIN var nextOfKin = registration.NEXT_OF_KIN; //Get CCCNumber and NationalId string nationalId = String.Empty; string cccNumber = String.Empty; int entryPointId = 0; var lookupEntryPoints = lookupLogic.GetItemIdByGroupAndItemName("Entrypoint", registration.PATIENT_VISIT.PATIENT_SOURCE); if (lookupEntryPoints.Count > 0) { entryPointId = lookupEntryPoints[0].ItemId; } else { entryPointId = lookupLogic.GetItemIdByGroupAndDisplayName("Entrypoint", "Other")[0].ItemId; } foreach (var internalpatientid in registration.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID) { if (internalpatientid.IDENTIFIER_TYPE == "NATIONAL_ID" && internalpatientid.ASSIGNING_AUTHORITY == "GOK") { nationalId = internalpatientid.ID; } if (internalpatientid.IDENTIFIER_TYPE == "CCC_NUMBER" && internalpatientid.ASSIGNING_AUTHORITY == "CCC") { cccNumber = internalpatientid.ID; } } if (!String.IsNullOrWhiteSpace(cccNumber)) { patient = patientLookup.GetPatientByCccNumber(cccNumber); if (patient == null) { msg = ProcessPatient.Add(firstName, middleName, lastName, sex, interopUserId, DOB, DOB_Precision, facilityId, patientType, nationalId, visitType, dateOfEnrollment, cccNumber, entryPointId, godsNumber, maritalStatusId, village, wardId, subCountyId, countyId, nearestLandMark, postalAdress, phoneNumber, DateOfDeath, nextOfKin); } else { msg = ProcessPatient.Update(firstName, middleName, lastName, sex, patient.PersonId, patient.Id, patient.ptn_pk, DOB, DOB_Precision, nationalId, facilityId, entryPointId, dateOfEnrollment, cccNumber, patient, godsNumber, maritalStatusId, village, wardId, subCountyId, countyId, nearestLandMark, postalAdress, phoneNumber, DateOfDeath, nextOfKin, interopUserId); } } } catch (Exception ex) { throw new Exception(ex.Message); } return(msg); }
public static string Update(PatientAppointSchedulingDTO appointmentScheduling) { try { //todo: fetch assigning facility from the message string assigning_Facility = ""; PatientAppointmentManager manager = new PatientAppointmentManager(); PatientLookupManager patientLookup = new PatientLookupManager(); LookupLogic lookupLogic = new LookupLogic(); PatientMasterVisitManager masterVisitManager = new PatientMasterVisitManager(); var personIdentifierManager = new PersonIdentifierManager(); var interopPlacerValuesManager = new InteropPlacerValuesManager(); PatientLookup patient = new PatientLookup(); string cccNumber = String.Empty; string appointmentReason = String.Empty; string appointmentStatus = String.Empty; string appointmentType = String.Empty; int interopUserId = InteropUser.UserId; foreach (var item in appointmentScheduling.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID) { if (item.IDENTIFIER_TYPE == "CCC_NUMBER" && item.ASSIGNING_AUTHORITY == "CCC") { cccNumber = item.ID; } } string godsNumber = appointmentScheduling.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.ID; if (!String.IsNullOrWhiteSpace(cccNumber)) { patient = patientLookup.GetPatientByCccNumber(cccNumber); if (patient != null) { if (!string.IsNullOrWhiteSpace(godsNumber)) { IdentifierManager identifierManager = new IdentifierManager(); Identifier identifier = identifierManager.GetIdentifierByCode("GODS_NUMBER"); var personIdentifiers = personIdentifierManager.GetPersonIdentifiers(patient.PersonId, identifier.Id); if (personIdentifiers.Count == 0) { personIdentifierManager.AddPersonIdentifier(patient.PersonId, identifier.Id, godsNumber, interopUserId, assigning_Facility); } } int patientMasterVisitId = masterVisitManager.GetLastPatientVisit(patient.Id).Id; int serviceAreaId = lookupLogic.GetItemIdByGroupAndItemName("ServiceArea", "MoH 257 GREENCARD")[0].ItemId; foreach (var appointment in appointmentScheduling.APPOINTMENT_INFORMATION) { switch (appointment.APPOINTMENT_REASON) { case "PHARMACY_REFILL": appointmentReason = "Pharmacy Refill"; break; case "TREATMENT_PREP": appointmentReason = "Treatment Preparation"; break; case "LAB_TEST": appointmentReason = "Lab Tests"; break; case "FOLLOWUP": appointmentReason = "Follow Up"; break; default: appointmentReason = "Follow Up"; break; } switch (appointment.APPOINTMENT_STATUS) { case "HONORED": appointmentStatus = "Met"; break; case "MISSED": appointmentStatus = "Missed"; break; case "PENDING": appointmentStatus = "Pending"; break; case "CANCELLED": appointmentStatus = "CareEnded"; break; default: appointmentStatus = "Pending"; break; } switch (appointment.APPOINTMENT_TYPE) { case "CLINICAL": appointmentType = "Standard Care"; break; case "PHARMACY": appointmentType = "Express Care"; break; case "INVESTIGATION": appointmentType = "Express Care"; break; default: appointmentType = "Standard Care"; break; } var reasons = lookupLogic.GetItemIdByGroupAndItemName("AppointmentReason", appointmentReason); int reasonId = 0; if (reasons == null || reasons.Count > 0) { throw new Exception($"No matching reasons in the databases {appointmentReason}"); } reasonId = reasons[0].ItemId; int statusId = 0; var status = lookupLogic.GetItemIdByGroupAndItemName("AppointmentStatus", appointmentStatus); if (status == null || status.Count > 0) { throw new Exception($"No matching appointmentstatus in the databases {appointmentStatus}"); } statusId = status[0].ItemId; int differentiatedCareId = 0; var diffCare = lookupLogic.GetItemIdByGroupAndItemName("DifferentiatedCare", appointmentType); if (diffCare == null || diffCare.Count > 0) { throw new Exception($"No matching differentiated care option in the databases {appointmentType}"); } differentiatedCareId = diffCare[0].ItemId; InteropPlacerTypeManager interopPlacerTypeManager = new InteropPlacerTypeManager(); int interopPlacerTypeId = interopPlacerTypeManager.GetInteropPlacerTypeByName(appointment.PLACER_APPOINTMENT_NUMBER.ENTITY).Id; var interopPlacerValues = interopPlacerValuesManager.GetInteropPlacerValues(interopPlacerTypeId, 3, appointment.PLACER_APPOINTMENT_NUMBER.NUMBER); if (interopPlacerValues != null) { PatientAppointment patientAppointment = manager.GetPatientAppointment(interopPlacerValues.EntityId); patientAppointment.AppointmentDate = DateTime.ParseExact(appointment.APPOINTMENT_DATE, "yyyyMMdd", null); patientAppointment.Description = appointment.APPOINTMENT_NOTE; patientAppointment.DifferentiatedCareId = differentiatedCareId; patientAppointment.ReasonId = reasonId; patientAppointment.ServiceAreaId = serviceAreaId; patientAppointment.StatusId = statusId; manager.UpdatePatientAppointments(patientAppointment); } else { PatientAppointment patientAppointment = new PatientAppointment() { PatientId = patient.Id, PatientMasterVisitId = patientMasterVisitId, AppointmentDate = DateTime.ParseExact(appointment.APPOINTMENT_DATE, "yyyyMMdd", null), Description = appointment.APPOINTMENT_NOTE, DifferentiatedCareId = differentiatedCareId, ReasonId = reasonId, ServiceAreaId = serviceAreaId, StatusId = statusId, CreatedBy = interopUserId, CreateDate = DateTime.Now }; int appointmentId = manager.AddPatientAppointments(patientAppointment, false); InteropPlacerValues placerValues = new InteropPlacerValues() { IdentifierType = 3, EntityId = appointmentId, InteropPlacerTypeId = interopPlacerTypeId, PlacerValue = appointment.PLACER_APPOINTMENT_NUMBER.NUMBER }; interopPlacerValuesManager.AddInteropPlacerValue(placerValues); } } } } } catch (Exception e) { throw new Exception(e.Message); } return(String.Empty); }