public static ObservationResultDTO GetVitals(int patientId, int patientMasterVisitId) { ObservationResultDTO observationResult = new ObservationResultDTO(); try { PatientMessageManager patientMessageManager = new PatientMessageManager(); PatientMessage patientMessage = patientMessageManager.GetPatientMessageByEntityId(patientId); if (patientMessage != null) { PersonIdentifierManager personIdentifierManager = new PersonIdentifierManager(); IdentifierManager identifierManager = new IdentifierManager(); Identifier identifier = identifierManager.GetIdentifierByCode("GODS_NUMBER"); //Initialize default values observationResult.PATIENT_IDENTIFICATION = observationResult.PATIENT_IDENTIFICATION == null ? new OBSERVATIONPATIENTIDENTIFICATION() : observationResult.PATIENT_IDENTIFICATION; observationResult.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID = observationResult.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID == null ? new List <INTERNALPATIENTID>() : observationResult.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID; observationResult.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID = observationResult.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID == null ? new EXTERNALPATIENTID() : observationResult.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID; observationResult.PATIENT_IDENTIFICATION.PATIENT_NAME = observationResult.PATIENT_IDENTIFICATION.PATIENT_NAME == null ? new PATIENTNAME() : observationResult.PATIENT_IDENTIFICATION.PATIENT_NAME; observationResult.OBSERVATION_RESULT = observationResult.OBSERVATION_RESULT == null ? new List <OBSERVATION_RESULT>() : observationResult.OBSERVATION_RESULT; //External Patient Id List <PersonIdentifier> personIdentifiers = personIdentifierManager.GetPersonIdentifiers(patientMessage.Id, identifier.Id); observationResult.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID = PatientIdentificationSegment.GetExternalPatientId(personIdentifiers); //CCC Number INTERNALPATIENTID internalPatientId = PatientIdentificationSegment.getInternalPatientIdCCC(patientMessage); observationResult.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Add(internalPatientId); //National ID if (!String.IsNullOrWhiteSpace(patientMessage.NATIONAL_ID) && patientMessage.NATIONAL_ID != "99999999") { INTERNALPATIENTID internalNationalId = PatientIdentificationSegment.getInternalPatientIdNationalId(patientMessage); observationResult.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Add(internalNationalId); } //Patient Names observationResult.PATIENT_IDENTIFICATION.PATIENT_NAME = PatientIdentificationSegment.GetPatientName(patientMessage); //get vitals observation PatientVitalsMessageManager patientVitalsMessage = new PatientVitalsMessageManager(); PatientVitalsMessage patientVitals = patientVitalsMessage.GetPatientVitalsMessageByPatientIdPatientMasterVisitId(patientId, patientMasterVisitId); if (patientVitals != null) { OBSERVATION_RESULT observationHeight = new OBSERVATION_RESULT() { OBSERVATION_IDENTIFIER = "START_HEIGHT", OBSERVATION_SUB_ID = "", CODING_SYSTEM = "", VALUE_TYPE = "NM", OBSERVATION_VALUE = patientVitals.Height.ToString(), UNITS = patientVitals.HeightUnits, OBSERVATION_RESULT_STATUS = "F", OBSERVATION_DATETIME = patientVitals.VisitDate, ABNORMAL_FLAGS = "N" }; OBSERVATION_RESULT observationWeight = new OBSERVATION_RESULT() { OBSERVATION_IDENTIFIER = "START_WEIGHT", OBSERVATION_SUB_ID = "", CODING_SYSTEM = "", VALUE_TYPE = "NM", OBSERVATION_VALUE = patientVitals.Weight.ToString(), UNITS = patientVitals.WeightUnits, OBSERVATION_RESULT_STATUS = "F", OBSERVATION_DATETIME = patientVitals.VisitDate, ABNORMAL_FLAGS = "N" }; observationResult.OBSERVATION_RESULT.Add(observationHeight); observationResult.OBSERVATION_RESULT.Add(observationWeight); } } return(observationResult); } catch (Exception e) { Console.WriteLine(e); throw; } }
public static ObservationResultDTO GetWHOStage(int entityId) { try { ObservationResultDTO observationResult = new ObservationResultDTO(); PatientWhoStageManager whoStageManager = new PatientWhoStageManager(); var whoStage = whoStageManager.GetWhoStageById(entityId); if (whoStage != null) { LookupLogic lookupLogic = new LookupLogic(); PatientMasterVisitManager visitManager = new PatientMasterVisitManager(); PersonIdentifierManager personIdentifierManager = new PersonIdentifierManager(); IdentifierManager identifierManager = new IdentifierManager(); Identifier identifier = identifierManager.GetIdentifierByCode("GODS_NUMBER"); PatientMessageManager patientMessageManager = new PatientMessageManager(); PatientMessage patientMessage = patientMessageManager.GetPatientMessageByEntityId(whoStage.PatientId); PatientMasterVisit visit = visitManager.GetVisitById(whoStage.PatientMasterVisitId); List <PersonIdentifier> personIdentifiers = personIdentifierManager.GetPersonIdentifiers(patientMessage.Id, identifier.Id); string whoStageString = lookupLogic.GetLookupItemNameByMasterNameItemId(whoStage.WHOStage, "WHOStage"); //Initialize default values observationResult.PATIENT_IDENTIFICATION = observationResult.PATIENT_IDENTIFICATION == null ? new OBSERVATIONPATIENTIDENTIFICATION() : observationResult.PATIENT_IDENTIFICATION; observationResult.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID = observationResult.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID == null ? new List <INTERNALPATIENTID>() : observationResult.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID; observationResult.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID = observationResult.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID == null ? new EXTERNALPATIENTID() : observationResult.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID; observationResult.PATIENT_IDENTIFICATION.PATIENT_NAME = observationResult.PATIENT_IDENTIFICATION.PATIENT_NAME == null ? new PATIENTNAME() : observationResult.PATIENT_IDENTIFICATION.PATIENT_NAME; observationResult.OBSERVATION_RESULT = observationResult.OBSERVATION_RESULT == null ? new List <OBSERVATION_RESULT>() : observationResult.OBSERVATION_RESULT; //External Patient Id observationResult.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID = PatientIdentificationSegment.GetExternalPatientId(personIdentifiers); //CCC Number INTERNALPATIENTID internalPatientId = PatientIdentificationSegment.getInternalPatientIdCCC(patientMessage); observationResult.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Add(internalPatientId); //National ID INTERNALPATIENTID internalNationalId = PatientIdentificationSegment.getInternalPatientIdNationalId(patientMessage); if (internalNationalId != null) { observationResult.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Add(internalNationalId); } //Patient Names observationResult.PATIENT_IDENTIFICATION.PATIENT_NAME = PatientIdentificationSegment.GetPatientName(patientMessage); //set visitdate value DateTime visitDate = visit.VisitDate.HasValue ? visit.VisitDate.Value : DateTime.Now; string observationDate = visitDate.ToString("yyyyMMddHmmss", CultureInfo.InvariantCulture); string observationValue = String.Empty; switch (whoStageString) { case "Stage1": observationValue = "1"; break; case "Stage2": observationValue = "2"; break; case "Stage3": observationValue = "3"; break; case "Stage4": observationValue = "4"; break; } //WHO STAGE OBSERVATION_RESULT observation = new OBSERVATION_RESULT() { OBSERVATION_IDENTIFIER = "WHO_STAGE", OBSERVATION_SUB_ID = "", CODING_SYSTEM = "WHO", VALUE_TYPE = "NM", OBSERVATION_VALUE = observationValue, UNITS = "", OBSERVATION_RESULT_STATUS = "F", OBSERVATION_DATETIME = observationDate, ABNORMAL_FLAGS = "N" }; observationResult.OBSERVATION_RESULT.Add(observation); } return(observationResult); } catch (Exception e) { throw e; } }
public static PatientAppointSchedulingDTO Get(int entityId) { try { PatientAppointmentMessageManager appointmentManager = new PatientAppointmentMessageManager(); PatientAppointmentMessage appointmentMessage = appointmentManager.GetPatientAppointmentMessageById(entityId); PatientAppointSchedulingDTO appointmentScheduling = new PatientAppointSchedulingDTO(); if (appointmentMessage != null) { PatientMessageManager patientMessageManager = new PatientMessageManager(); PatientMessage patientMessage = patientMessageManager.GetPatientMessageByEntityId(appointmentMessage.PatientId); var personIdentifierManager = new PersonIdentifierManager(); if (patientMessage != null) { IdentifierManager identifierManager = new IdentifierManager(); Identifier identifier = identifierManager.GetIdentifierByCode("GODS_NUMBER"); var personIdentifiers = personIdentifierManager.GetPersonIdentifiers(patientMessage.Id, identifier.Id); appointmentScheduling.PATIENT_IDENTIFICATION = appointmentScheduling.PATIENT_IDENTIFICATION == null ? new APPOINTMENTPATIENTIDENTIFICATION() : appointmentScheduling.PATIENT_IDENTIFICATION; appointmentScheduling.APPOINTMENT_INFORMATION = appointmentScheduling.APPOINTMENT_INFORMATION == null ? new List <APPOINTMENT_INFORMATION>() : appointmentScheduling.APPOINTMENT_INFORMATION; appointmentScheduling.PATIENT_IDENTIFICATION.PATIENT_NAME = appointmentScheduling.PATIENT_IDENTIFICATION.PATIENT_NAME == null ? new PATIENTNAME() : appointmentScheduling.PATIENT_IDENTIFICATION.PATIENT_NAME; appointmentScheduling.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID = appointmentScheduling.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID == null ? new List <INTERNALPATIENTID>() : appointmentScheduling.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID; appointmentScheduling.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID = appointmentScheduling.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID == null ? new EXTERNALPATIENTID() : appointmentScheduling.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID; INTERNALPATIENTID internalPatientId = new INTERNALPATIENTID(); internalPatientId.ID = patientMessage.IdentifierValue; internalPatientId.IDENTIFIER_TYPE = "CCC_NUMBER"; internalPatientId.ASSIGNING_AUTHORITY = "CCC"; appointmentScheduling.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Add(internalPatientId); if (!String.IsNullOrWhiteSpace(patientMessage.NATIONAL_ID) && patientMessage.NATIONAL_ID != "99999999") { INTERNALPATIENTID internalNationalId = new INTERNALPATIENTID(); internalNationalId.ID = patientMessage.NATIONAL_ID; internalNationalId.IDENTIFIER_TYPE = "NATIONAL_ID"; internalNationalId.ASSIGNING_AUTHORITY = "GOK"; appointmentScheduling.PATIENT_IDENTIFICATION.INTERNAL_PATIENT_ID.Add(internalNationalId); } //External Patient Id appointmentScheduling.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.ID = personIdentifiers.Count > 0 ? personIdentifiers[0].IdentifierValue : String.Empty; appointmentScheduling.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.ASSIGNING_AUTHORITY = "MPI"; appointmentScheduling.PATIENT_IDENTIFICATION.EXTERNAL_PATIENT_ID.IDENTIFIER_TYPE = "GODS_NUMBER"; //set names appointmentScheduling.PATIENT_IDENTIFICATION.PATIENT_NAME.FIRST_NAME = !string.IsNullOrWhiteSpace(patientMessage.FIRST_NAME) ? patientMessage.FIRST_NAME : ""; appointmentScheduling.PATIENT_IDENTIFICATION.PATIENT_NAME.MIDDLE_NAME = !string.IsNullOrWhiteSpace(patientMessage.MIDDLE_NAME) ? patientMessage.MIDDLE_NAME : ""; appointmentScheduling.PATIENT_IDENTIFICATION.PATIENT_NAME.LAST_NAME = !string.IsNullOrWhiteSpace(patientMessage.LAST_NAME) ? patientMessage.LAST_NAME : ""; string appointmentReason = String.Empty; string appointmentType = String.Empty; string appointmentLocation = String.Empty; string appointmentStatus = String.Empty; switch (appointmentMessage.AppointmentReason) { case "Pharmacy Refill": appointmentReason = "PHARMACY_REFILL"; break; case "Treatment Preparation": appointmentReason = "TREATMENT_PREP"; break; case "Lab Tests": appointmentReason = "LAB_TEST"; break; case "Follow Up": appointmentReason = "FOLLOWUP"; break; default: appointmentReason = "FOLLOWUP"; break; } switch (appointmentMessage.AppointmentType) { case "Standard Care": appointmentType = "CLINICAL"; break; case "Express Care": appointmentType = "PHARMACY"; break; case "Community Based Dispensing": appointmentType = "PHARMACY"; break; default: appointmentType = "CLINICAL"; break; } switch (appointmentMessage.AppointmentReason) { case "Pharmacy Refill": appointmentLocation = "PHARMACY"; break; case "Treatment Preparation": appointmentLocation = "CLINIC"; break; case "Lab Tests": appointmentLocation = "LAB"; break; case "Follow Up": appointmentLocation = "CLINIC"; break; default: appointmentLocation = "CLINIC"; break; } switch (appointmentMessage.AppointmentStatus) { case "PreviouslyMissed": appointmentStatus = "MISSED"; break; case "CareEnded": appointmentStatus = "CANCELLED"; break; case "Met": appointmentStatus = "HONORED"; break; case "Missed": appointmentStatus = "MISSED"; break; case "Pending": appointmentStatus = "PENDING"; break; } //set appointment information APPOINTMENT_INFORMATION appointmentInformation = new APPOINTMENT_INFORMATION() { PLACER_APPOINTMENT_NUMBER = new PLACER_APPOINTMENT_NUMBER() { NUMBER = appointmentMessage.AppointmentId.ToString(), ENTITY = "IQCARE" }, APPOINTMENT_REASON = appointmentReason, APPOINTMENT_TYPE = appointmentType, APPOINTMENT_DATE = appointmentMessage.AppointmentDate, APPOINTMENT_PLACING_ENTITY = "IQCARE", APPOINTMENT_LOCATION = appointmentLocation, ACTION_CODE = "A", APPOINTMENT_NOTE = appointmentMessage.Description, APPOINTMENT_STATUS = appointmentStatus }; appointmentScheduling.APPOINTMENT_INFORMATION.Add(appointmentInformation); } } return(appointmentScheduling); } catch (Exception e) { throw new Exception(e.Message); } }