public PatientProblemVoCollection listPatientProblemsByCareContext(CareContextRefVo careContext) {
    if (careContext == null || careContext.getID_CareContext() == null)
      throw new CodingRuntimeException("No Care context Supplied");

    DomainFactory factory = getDomainFactory();
    List problems =
        factory.find(
            "from PatientProblem p where p.careContext.id = :careContextId order by p.specialty.text, p.problem.pCName",
            new String[] {"careContextId"},
            new Object[] {careContext.getID_CareContext()});

    return PatientProblemVoAssembler.createPatientProblemVoCollectionFromPatientProblem(problems);
  }
Esempio n. 2
0
  public Boolean hasAssessmentSavedOrOneConfiguredForSpecialty(
      CareContextRefVo careContext, Specialty specialty) {
    DomainFactory factory = getDomainFactory();

    String query =
        "select count(dd.id) from DischargeDetails dd where dd.careContext.id = :careContextId and dd.patientAssessment is not null";

    Object[] count =
        factory
            .find(
                query,
                new String[] {"careContextId"},
                new Object[] {careContext.getID_CareContext()})
            .toArray();
    if (count != null && count.length > 0 && ((Long) count[0]).intValue() > 0) {
      return true;
    } else {
      query =
          "select count(dd.id) from DischargeDetails dd left join dd.dischargeLetterStatus as dls where dd.careContext.id = :careContextId and dls.id = :Generated";

      count =
          factory
              .find(
                  query,
                  new String[] {"careContextId", "Generated"},
                  new Object[] {
                    careContext.getID_CareContext(), DischargeLetterStatus.GENERATED.getID()
                  })
              .toArray();
      if (count != null && count.length > 0 && ((Long) count[0]).intValue() > 0) {
        return false;
      }

      query =
          "select count(u.id) from UserAssessment u left join u.assessmentSpecialties assSpec where assSpec.instance = :assessmentSpec and u.activeStatus = :actStat";

      count =
          factory
              .find(
                  query,
                  new String[] {"assessmentSpec", "actStat"},
                  new Object[] {
                    getDomLookup(specialty), getDomLookup(PreActiveActiveInactiveStatus.ACTIVE)
                  })
              .toArray();

      if (count != null && count.length > 0 && ((Long) count[0]).intValue() > 0) return true;

      return false;
    }
  }
  public PatientDiagnosisAtConsultationVoCollection listPatientDiagnosis(
      CareContextRefVo attendance) {
    if (attendance == null || attendance.getID_CareContext() == null) return null;

    DomainFactory factory = getDomainFactory();
    String query =
        "select pd from PatientDiagnosis as pd left join pd.careContext as cc where cc.id = :AttendenceId order by UPPER(pd.diagnosisDescription) asc";

    List<?> list =
        factory.find(
            query, new String[] {"AttendenceId"}, new Object[] {attendance.getID_CareContext()});

    return PatientDiagnosisAtConsultationVoAssembler
        .createPatientDiagnosisAtConsultationVoCollectionFromPatientDiagnosis(list);
  }
  public InvestigationAttendenceDetailVoCollection listInvestigationAttendence(
      CareContextRefVo careContext) {
    if (careContext == null || careContext.getID_CareContext() == null) return null;

    DomainFactory factory = getDomainFactory();
    String query =
        "select ia from InvestigationAttendenceDetail as ia left join ia.attendance as at left join ia.attendenceInvestigation as ai where at.id = :AttendenceId and ia.active = 1 order by UPPER(ai.text) asc";

    List<?> list =
        factory.find(
            query, new String[] {"AttendenceId"}, new Object[] {careContext.getID_CareContext()});

    return InvestigationAttendenceDetailVoAssembler
        .createInvestigationAttendenceDetailVoCollectionFromInvestigationAttendenceDetail(list);
  }
Esempio n. 5
0
  /** get Discharge Details */
  public ims.clinical.vo.DischargeDetailsVo getDischargeDetails(
      ims.core.admin.vo.CareContextRefVo careContextRefvo) {
    if (careContextRefvo == null)
      throw new CodingRuntimeException("careContextRefVo Filter not provided for list call. ");

    if (careContextRefvo != null) {
      DomainFactory factory = getDomainFactory();
      StringBuffer hql = new StringBuffer(" from DischargeDetails dd where ");
      String andStr = " ";

      ArrayList<String> markers = new ArrayList<String>();
      ArrayList<Serializable> values = new ArrayList<Serializable>();

      hql.append(andStr + " dd.careContext.id = :careContextId");
      markers.add("careContextId");
      values.add(careContextRefvo.getID_CareContext());
      andStr = " and ";

      List list = factory.find(hql.toString(), markers, values);
      if (list != null && list.size() > 0) {
        DischargeDetailsVoCollection voColl =
            DischargeDetailsVoAssembler.createDischargeDetailsVoCollectionFromDischargeDetails(
                list);
        if (voColl != null && voColl.size() > 0) return voColl.get(0);
      }
    }
    return null;
  }
Esempio n. 6
0
  public DischargeSupplementaryNotesVo getSupplementary(CareContextRefVo voCareContextRefVo) {
    if (voCareContextRefVo == null)
      throw new CodingRuntimeException("voCareContextRefVo Filter not provided for list call. ");

    if (voCareContextRefVo != null) {
      DomainFactory factory = getDomainFactory();
      StringBuffer hql = new StringBuffer(" from DischargeSupplementaryNotes ds where ");
      String andStr = " ";

      ArrayList<String> markers = new ArrayList<String>();
      ArrayList<Serializable> values = new ArrayList<Serializable>();

      hql.append(andStr + " ds.careContext.id = :careContextId");
      markers.add("careContextId");
      values.add(voCareContextRefVo.getID_CareContext());
      andStr = " and ";

      List list = factory.find(hql.toString(), markers, values);
      if (list != null && list.size() > 0) {
        DischargeSupplementaryNotesVoCollection voColl =
            DischargeSupplementaryNotesVoAssembler
                .createDischargeSupplementaryNotesVoCollectionFromDischargeSupplementaryNotes(list);
        if (voColl != null && voColl.size() > 0) return voColl.get(0);
      }
    }
    return null;
  }
  public AttendDiagInvTreatStatusVo getAttendDiagInvTreatStatus(CareContextRefVo careContextRef) {
    if (careContextRef == null || careContextRef.getID_CareContext() == null) return null;

    DomainFactory factory = getDomainFactory();

    String queryNoKnownInvestigationSaved =
        "SELECT attendDiagInvTreatStatus  from AttendDiagInvTreatStatus as attendDiagInvTreatStatus left join attendDiagInvTreatStatus.attendance as at where (at.id = :AttendenceId and (attendDiagInvTreatStatus.isRIE is null OR attendDiagInvTreatStatus.isRIE = 0) ) ";
    AttendDiagInvTreatStatus doAttendDiagInvTreatStatus =
        (AttendDiagInvTreatStatus)
            factory.findFirst(
                queryNoKnownInvestigationSaved,
                new String[] {"AttendenceId"},
                new Object[] {careContextRef.getID_CareContext()});

    return AttendDiagInvTreatStatusVoAssembler.create(doAttendDiagInvTreatStatus);
  }
  // WDEV-19918 - MAXIMS 10.1.2
  public Boolean existAttendanceNotes(
      PatientRefVo patientRef,
      CareContextRefVo careContextRef,
      AttendanceClinicalNoteType noteType) {
    if (patientRef == null)
      throw new CodingRuntimeException(
          "Cannot list AttendanceClinicalNotes for a null Patient Id.");

    String hql =
        "select count(attClinicalNotes.id) from AttendanceClinicalNotes as attClinicalNotes ";
    StringBuffer hqlConditions = new StringBuffer();

    ArrayList<String> markers = new ArrayList<String>();
    ArrayList<Object> values = new ArrayList<Object>();

    String andStr = "";

    if (patientRef != null) {
      hqlConditions.append(andStr);
      hqlConditions.append("attClinicalNotes.patient.id = :PatientId ");
      markers.add("PatientId");
      values.add(patientRef.getID_Patient());
      andStr = " and ";
    }

    if (careContextRef != null) {
      hqlConditions.append(andStr);
      hqlConditions.append(" attClinicalNotes.attendance.id = :CareContextId ");
      markers.add("CareContextId");
      values.add(careContextRef.getID_CareContext());
      andStr = " and ";
    }

    if (noteType != null) {
      hqlConditions.append(andStr);
      hqlConditions.append("attClinicalNotes.noteType.id = :noteTypeId ");
      markers.add("noteTypeId");
      values.add(noteType.getID());
      andStr = " and ";
    }

    if (hqlConditions.length() > 0) {
      hqlConditions.insert(0, " where (");
      hqlConditions.append(" ) ");
    }

    hqlConditions.append(
        andStr + " (attClinicalNotes.isRIE is null OR attClinicalNotes.isRIE = 0) ");

    hql = hql + hqlConditions.toString();

    DomainFactory factory = getDomainFactory();

    List<?> list = factory.find(hql, markers, values);

    if (list != null && list.size() > 0 && ((Long) list.get(0)).intValue() > 0) return true;

    return false;
  }
  public EmergencyAttendanceInvestigationCodingVo getInvestigationSequence(
      CareContextRefVo emergencyAttendance) {
    if (emergencyAttendance == null || emergencyAttendance.getID_CareContext() == null) return null;

    DomainFactory factory = getDomainFactory();
    String query =
        "select eaic from EmergencyAttendanceInvestigationCoding as eaic left join eaic.careContext as cc where cc.id = :ccID";

    List<?> list =
        factory.find(
            query, new String[] {"ccID"}, new Object[] {emergencyAttendance.getID_CareContext()});
    if (list != null && list.size() > 0)
      return EmergencyAttendanceInvestigationCodingVoAssembler.create(
          (EmergencyAttendanceInvestigationCoding) list.get(0));

    return null;
  }
  public InterventionsTreatmentsForAttendenceVo getInterventionsTreatmentsForAttendence(
      CareContextRefVo attendence) {
    if (attendence == null || attendence.getID_CareContext() == null) return null;

    DomainFactory factory = getDomainFactory();
    String query =
        "select it from InterventionsTreatmentsForAttendence as it where it.attendance.id = :AttendenceId ";

    List<?> list =
        factory.find(
            query, new String[] {"AttendenceId"}, new Object[] {attendence.getID_CareContext()});

    if (list == null || list.size() == 0) return null;

    return InterventionsTreatmentsForAttendenceVoAssembler.create(
        (InterventionsTreatmentsForAttendence) list.get(0));
  }
Esempio n. 11
0
  private TriageForRIETriageAssessmentVo getTriage(CareContextRefVo careContext) {
    String query =
        "SELECT trg FROM Triage AS trg LEFT JOIN trg.attendance AS attd WHERE attd.id = :CONTEXT_ID and (trg.isRIE is null OR trg.isRIE = 0)";

    return TriageForRIETriageAssessmentVoAssembler.create(
        (Triage)
            getDomainFactory().findFirst(query, "CONTEXT_ID", careContext.getID_CareContext()));
  }
Esempio n. 12
0
  public CareContextShortVo getCareContextShortVo(CareContextRefVo careContextRef) {
    if (careContextRef == null)
      throw new RuntimeException("Cannot get CareContextShortVo for null CareContextRefVo");

    CareContext doCareContext =
        (CareContext)
            getDomainFactory()
                .getDomainObject(CareContext.class, careContextRef.getID_CareContext());
    return CareContextShortVoAssembler.create(doCareContext);
  }
Esempio n. 13
0
  public DischargeReportDetailVo getDischargeReportDetailsForCareContext(
      CareContextRefVo careContext) {
    if (careContext == null || careContext.getID_CareContext() == null)
      throw new CodingRuntimeException(
          "CareContext is null or id not provided for getDischargeDetailsForCareContext");

    DomainFactory factory = getDomainFactory();
    List domainObjectList =
        factory.find(
            "select drd from DischargeReportDetail as drd left join drd.careContext as cc where cc.id = :idCareContext",
            new String[] {"idCareContext"},
            new Object[] {careContext.getID_CareContext()});
    DischargeReportDetailVoCollection reportDetail =
        DischargeReportDetailVoAssembler
            .createDischargeReportDetailVoCollectionFromDischargeReportDetail(domainObjectList);

    return reportDetail != null && reportDetail.size() > 0
        ? (reportDetail.get(0) != null ? reportDetail.get(0) : null)
        : null;
  }
  public EmergencyPatientPresentingProblemsVo getEmergencyPresentingProblems(
      CareContextRefVo careContextRef) {
    if (careContextRef == null || careContextRef.getID_CareContext() == null)
      throw new CodingRuntimeException("No Care context Supplied");

    DomainFactory factory = getDomainFactory();
    List problems =
        factory.find(
            "from PresProblemsProceduresPerformed p where p.careContext.id = :careContextId",
            new String[] {"careContextId"},
            new Object[] {careContextRef.getID_CareContext()});

    if (problems.size() > 1)
      throw new DomainRuntimeException("More than 1 record found for current Care context !");

    return problems.size() == 0
        ? null
        : EmergencyPatientPresentingProblemsVoAssembler.create(
            (PresProblemsProceduresPerformed) problems.get(0));
  }
Esempio n. 15
0
  public void markTriageAsRIE(
      TriageProtocolAssessmentShortVo triageAssessment,
      FormName formName,
      PatientRefVo patient,
      CareContextRefVo careContext,
      String messageRIE)
      throws StaleObjectException, DomainInterfaceException {
    if (triageAssessment == null || triageAssessment.getID_TriageProtocolAssessment() == null)
      throw new CodingRuntimeException("Cannot RIE the records not saved.");

    // Get the Triage to check if it is the current Triage Assessment
    TriageForRIETriageAssessmentVo triage = getTriage(careContext);

    if (triage != null) {
      if (triage.getInitialTriageAssessment() == null
          || triageAssessment.equals(triage.getInitialTriageAssessment()))
        throw new DomainInterfaceException("Cannot record in error initial triage.");

      if (triageAssessment.equals(triage.getCurrentTriageAssessment())) {
        // Get the previous triage Assessment
        TriageProtocolAssessmentShortVo previousAssessment =
            getPreviousProtocolAssessment(
                careContext,
                triageAssessment.getAssessmentDateTime(),
                triage.getCurrentTriageAssessment());

        if (previousAssessment == null) return; // TODO - cannot RIE past the initial triage

        // Update current triage Assessment
        triage.setCurrentTriageAssessment(previousAssessment);
        if (triage.getInitialTriageAssessment().equals(previousAssessment))
          triage.setTriagePriorityChange(null);
        else
          triage.setTriagePriorityChange(
              getPriorityChange(
                  triage.getInitialTriageAssessment().getTriagePriority(),
                  previousAssessment.getTriagePriority()));
        triage.setCurrentTriagePriority(previousAssessment.getTriagePriority());

        getDomainFactory()
            .save(
                TriageForRIETriageAssessmentVoAssembler.extractTriage(getDomainFactory(), triage));
      }
    }

    markAsRie(
        triageAssessment,
        formName,
        patient.getID_Patient(),
        null,
        careContext.getID_CareContext(),
        messageRIE);
  }
  public InvestigationsForAttendVo getInvestigationsForAttend(CareContextRefVo careContext) {
    DomainFactory factory = getDomainFactory();
    String query =
        "select ifa from InvestigationsForAttend as ifa left join ifa.attendance as cc where cc.id = :AttendenceId ";

    List<?> list =
        factory.find(
            query, new String[] {"AttendenceId"}, new Object[] {careContext.getID_CareContext()});

    if (list == null || list.size() == 0) return null;

    return InvestigationsForAttendVoAssembler.create((InvestigationsForAttend) list.get(0));
  }
Esempio n. 17
0
  private TriageProtocolAssessmentShortVo getPreviousProtocolAssessment(
      CareContextRefVo careContext,
      DateTime assessmentDateTime,
      TriageProtocolAssessmentRefVo currentTriageProtocol) {
    String query =
        "SELECT tp FROM TriageProtocolAssessment AS tp LEFT JOIN tp.attendance AS attend WHERE (tp.isRIE is null OR tp.isRIE = 0) AND tp.isMain = 1 AND tp.id <> :PROTOCOL_ID AND attend.id = :CONTEXT_ID AND tp.assessmentDateTime <= :PROT_DATETIME ORDER BY tp.assessmentDateTime DESC";

    ArrayList<String> paramNames = new ArrayList<String>();
    ArrayList<Object> paramValues = new ArrayList<Object>();
    paramNames.add("PROTOCOL_ID");
    paramValues.add(currentTriageProtocol.getID_TriageProtocolAssessment());
    paramNames.add("CONTEXT_ID");
    paramValues.add(careContext.getID_CareContext());
    paramNames.add("PROT_DATETIME");
    paramValues.add(assessmentDateTime.getJavaDate());

    return TriageProtocolAssessmentShortVoAssembler.create(
        (TriageProtocolAssessment) getDomainFactory().findFirst(query, paramNames, paramValues));
  }
Esempio n. 18
0
  public TriageProtocolAssessmentShortVoCollection listTriageProtocols(
      PatientRefVo patient, CareContextRefVo careContext) {
    if (patient == null || careContext == null)
      throw new CodingRuntimeException("Parameters patient and careContext are mandatory");

    String query =
        "SELECT tp FROM TriageProtocolAssessment AS tp LEFT JOIN tp.patient AS pat LEFT JOIN tp.attendance AS attend WHERE tp.isMain = 1 AND pat.id = :PAT_ID AND attend.id = :CONTEXT_ID ORDER BY tp.assessmentDateTime DESC";
    ArrayList<String> paramNames = new ArrayList<String>();
    ArrayList<Object> paramValues = new ArrayList<Object>();

    paramNames.add("PAT_ID");
    paramValues.add(patient.getID_Patient());

    paramNames.add("CONTEXT_ID");
    paramValues.add(careContext.getID_CareContext());

    return TriageProtocolAssessmentShortVoAssembler
        .createTriageProtocolAssessmentShortVoCollectionFromTriageProtocolAssessment(
            getDomainFactory().find(query, paramNames, paramValues));
  }
  public VitalSignMonitoringVoCollection listVitalSignsMonitoringVo(
      CareContextRefVo voCareContextRef) throws DomainInterfaceException {
    DomainFactory factory = getDomainFactory();
    StringBuffer hql = new StringBuffer("from VitalSignsMonitoring vsm ");

    if (voCareContextRef == null) return null;

    hql.append(" where vsm.careContext.id = :cc");

    hql.append(" order by vsm.startDateTime desc");

    java.util.List vsmList =
        factory.find(
            hql.toString(),
            new String[] {"cc"},
            new Object[] {voCareContextRef.getID_CareContext()});

    return VitalSignMonitoringVoAssembler
        .createVitalSignMonitoringVoCollectionFromVitalSignsMonitoring(vsmList);
  }
  public NeuroMotorFindingsVo getNeuroMotorFindingByCareContext(CareContextRefVo carecontextref) {
    if (carecontextref == null) throw new DomainRuntimeException("Care Context must not be null");

    DomainFactory factory = getDomainFactory();
    String hql =
        "from NeuExamMotor neuExamMotor where neuExamMotor.clinicalContact.contactType = :ClinContactType and neuExamMotor.careContext.id = :idCareContext";
    List list =
        factory.find(
            hql,
            new String[] {"ClinContactType", "idCareContext"},
            new Object[] {
              getDomLookup(ContactType.SPINALMEDICALADMISSION), carecontextref.getID_CareContext()
            });

    if (list != null && list.size() > 0) {
      NeuroMotorFindingsVoCollection collNeuroMotorFindings =
          NeuroMotorFindingsVoAssembler.createNeuroMotorFindingsVoCollectionFromNeuExamMotor(list);
      if (collNeuroMotorFindings != null && collNeuroMotorFindings.size() > 0)
        return collNeuroMotorFindings.get(0);
    }

    return null;
  }
  public WheelchairCushionVoCollection listByCareContext(CareContextRefVo refCareContext) {
    DomainFactory factory = getDomainFactory();
    StringBuffer hql = new StringBuffer(" ");
    String query = "from WheelchairCushion w ";
    ArrayList markers = new ArrayList();
    ArrayList values = new ArrayList();
    String andStr = " ";

    if (refCareContext != null) {
      hql.append(andStr + " w.careContext.id = :id_CareContext");
      markers.add("id_CareContext");
      values.add(refCareContext.getID_CareContext());
      andStr = " and ";
    }

    if (markers.size() > 0) query += " where ";
    query += hql.toString();

    List cushions = factory.find(query, markers, values);
    WheelchairCushionVoCollection collWheelchairCushion =
        WheelchairCushionVoAssembler.createWheelchairCushionVoCollectionFromWheelchairCushion(
            cushions);
    return collWheelchairCushion;
  }
  public OrderInvestigationForAttendenceNotesCcVoCollection listOrderInvestigations(
      PatientRefVo patient, CareContextRefVo careContext, String investigationsAlreadyAdded) {
    if (patient == null || patient.getID_Patient() == null)
      throw new CodingRuntimeException(
          "Patient parameter can not be null when listing OrderInvestigations.");

    DomainFactory factory = getDomainFactory();
    java.util.Date fromDate = null;
    java.util.Date dateTo = null;

    if (careContext != null && careContext.getID_CareContext() != null) {
      CareContext doCareContext =
          (CareContext) factory.getDomainObject(CareContext.class, careContext.getID_CareContext());
      if (doCareContext != null) {
        if (doCareContext.getStartDateTime() != null) {
          fromDate = doCareContext.getStartDateTime();
        }

        if (doCareContext.getEndDateTime() != null) {
          return null;
        }

        dateTo = new java.util.Date();
      }
    }

    StringBuilder query = new StringBuilder();

    ArrayList<String> paramNames = new ArrayList<String>();
    ArrayList<Object> paramValues = new ArrayList<Object>();

    query.append("SELECT orderInv FROM OrderInvestigation AS orderInv ");
    query.append(
        " LEFT JOIN FETCH orderInv.orderDetails AS details LEFT JOIN details.patient AS patient left join orderInv.investigation as inv left join inv.investigationIndex as invIndex left join orderInv.ordInvCurrentStatus.ordInvStatus as ordStatus ");

    query.append(
        "WHERE patient.id = :PATIENT_ID and ordStatus.id <> :cancelledStatusId and ordStatus.id <> :cancelRequestStatusId");
    paramNames.add("PATIENT_ID");
    paramValues.add(patient.getID_Patient());

    // WDEV-17303
    paramNames.add("cancelledStatusId");
    paramValues.add(OrderInvStatus.CANCELLED.getID());
    paramNames.add("cancelRequestStatusId");
    paramValues.add(OrderInvStatus.CANCEL_REQUEST.getID());

    if (fromDate != null && dateTo != null) {
      query.append(
          " AND orderInv.systemInformation.creationDateTime BETWEEN :FROM_DATE AND :END_DATE ");

      paramNames.add("FROM_DATE");
      paramValues.add(fromDate);
      paramNames.add("END_DATE");
      paramValues.add(dateTo);
    }

    if (investigationsAlreadyAdded != null && investigationsAlreadyAdded.length() > 0) {
      query.append(" AND orderInv.id not in (");
      query.append(investigationsAlreadyAdded);
      query.append(") ");
    }

    query.append(" order by UPPER(invIndex.name) asc");

    return OrderInvestigationForAttendenceNotesCcVoAssembler
        .createOrderInvestigationForAttendenceNotesCcVoCollectionFromOrderInvestigation(
            factory.find(query.toString(), paramNames, paramValues));
  }