String uid = patient.getUuid();
/** * Overridden here since the unique id is not on CohortMember directly * * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUniqueId(java.lang.Object) */ @Override protected String getUniqueId(CohortMember1_8 delegate) { return delegate.getPatient().getUuid(); }
private void cannotBePreviewed() { if ("testing-html-form-entry".equals(session.getPatient().getUuid())) throw new CannotBePreviewedException(); }
@PropertyGetter("patientUuid") public String getPatientUuid(CohortMembership cohortMembership) { if (cohortMembership.getPatientId() == null) { return null; } Patient patient = Context.getPatientService().getPatient(cohortMembership.getPatientId()); if (patient == null) { throw new IllegalStateException("CohortMembership " + cohortMembership.getUuid() + " refers to a patient that " + "does not exist: " + cohortMembership.getPatientId()); } return patient.getUuid(); }
if ("testing-html-form-entry".equals(session.getPatient().getUuid())) return false; else {
formObject = new SerializableFormObject(session.getXmlDefinition(), submission.getParameterMap(), patient.getPatientIdentifier().getIdentifier(), patient.getUuid(), encounter.getUuid(),session.getHtmlFormId()); } else if(patient==null || encounter==null) { if(log.isDebugEnabled()) log.debug("Either patient or encounter or both are null");
@Test public void shouldGetAPatientByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); Patient patient = service.getPatientByUuid(getUuid()); assertEquals(patient.getUuid(), PropertyUtils.getProperty(result, "uuid")); assertNotNull(PropertyUtils.getProperty(result, "identifiers")); assertNotNull(PropertyUtils.getProperty(result, "person")); assertNull(PropertyUtils.getProperty(result, "auditInfo")); }
@Test public void shouldGetAPatientProgramByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); PatientProgram patientProgram = service.getPatientProgramByUuid(getUuid()); Assert.assertNotNull(result); Assert.assertEquals(patientProgram.getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals(patientProgram.getPatient().getUuid(), ((Map) PropertyUtils.getProperty(result, "patient")).get("uuid")); Assert.assertEquals(patientProgram.getProgram().getUuid(), ((Map) PropertyUtils.getProperty(result, "program")).get("uuid")); }
/** * @verifies return location by tag uuid * @see LocationSearchHandler#getSearchConfig() */ @Test public void getSearchConfig_shouldReturnPatientByIdentifier() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.addParameter("identifier", "7TU-8"); SimpleObject result = deserialize(handle(req)); List<Object> hits = (List<Object>) result.get("results"); Assert.assertEquals(Context.getPatientService().getPatient(8).getUuid(), PropertyUtils.getProperty(hits.get(0), "uuid")); }
@Test public void getSearchConfig_shouldReturnPatientByIdentifier_matchExact() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.addParameter("identifier", "7TU-8"); req.addParameter("searchType", "exact"); SimpleObject result = deserialize(handle(req)); List<Object> hits = (List<Object>) result.get("results"); Assert.assertEquals(Context.getPatientService().getPatient(8).getUuid(), PropertyUtils.getProperty(hits.get(0), "uuid")); }
@Test public void shouldEnrollAPatientToAProgram() throws Exception { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); SimpleObject params = new SimpleObject(); params.add("patient", RestTestConstants1_8.PATIENT_UUID); params.add("program", RestTestConstants1_8.PROGRAM_UUID); params.add("dateEnrolled", dateFormat.format(new Date())); MockHttpServletRequest req = newPostRequest(getURI(), params); SimpleObject result = deserialize(handle(req)); Patient patient = patientService.getPatientByUuid(RestTestConstants1_8.PATIENT_IN_A_PROGRAM_UUID); List<PatientProgram> patientPrograms = service.getPatientPrograms(patient, null, null, null, null, null, true); PatientProgram newEnrollment = patientPrograms.get(patientPrograms.size() - 1); Assert.assertEquals(newEnrollment.getProgram().getUuid(), ((Map) result.get("program")).get("uuid")); Assert.assertEquals(newEnrollment.getPatient().getUuid(), ((Map) result.get("patient")).get("uuid")); Assert.assertNotNull(result.get("dateEnrolled")); }
@Override public void validateDefaultRepresentation() throws Exception { super.validateDefaultRepresentation(); assertPropEquals("startDate", startDate); assertPropEquals("endDate", endDate); // assertThat((String) result.get("startDate"), new SameDatetimeMatcher(startDate)); // assertThat((String) result.get("endDate"), new SameDatetimeMatcher(endDate)); String patientUuid = patientService.getPatient(6).getUuid(); assertPropEquals("patientUuid", patientUuid); assertThat(getRepresentation(), hasLink("patient", "/v1/patient/" + patientUuid)); }
@Test public void shouldGetTheActiveOrdersForAPatientAsOfTheSpecifiedDate() throws Exception { SimpleObject results = deserialize(handle(newGetRequest(getURI(), new Parameter("patient", patientService .getPatient(2).getUuid()), new Parameter("asOfDate", "2007-12-10")))); assertEquals(2, Util.getResultsSize(results)); results = deserialize(handle(newGetRequest(getURI(), new Parameter("patient", patientService.getPatient(2).getUuid()), new Parameter("asOfDate", "2007-12-10 00:01:00")))); assertEquals(1, Util.getResultsSize(results)); }
conditionSource.add("patient", patient.getUuid()); conditionSource.add("clinicalStatus", ConditionClinicalStatus.ACTIVE); conditionSource.add("verificationStatus", ConditionVerificationStatus.CONFIRMED); Assert.assertEquals(patient.get("uuid"), condition.getPatient().getUuid()); Assert.assertEquals(newConditionSource.get("clinicalStatus"), condition.getClinicalStatus().toString()); Assert.assertEquals(newConditionSource.get("verificationStatus"), condition.getVerificationStatus().toString());
conditionSource.add("patient", patient.getUuid()); conditionSource.add("clinicalStatus", ConditionClinicalStatus.ACTIVE); conditionSource.add("verificationStatus", ConditionVerificationStatus.CONFIRMED); Assert.assertEquals(patient.get("uuid"), condition.getPatient().getUuid()); Assert.assertEquals(newConditionSource.get("clinicalStatus"), condition.getClinicalStatus().toString()); Assert.assertEquals(newConditionSource.get("verificationStatus"), condition.getVerificationStatus().toString());
diagnosisSource.add("encounter", encounter.getUuid()); diagnosisSource.add("voided", false); diagnosisSource.add("patient", patient.getUuid()); Assert.assertEquals(diagnosis.getDiagnosis().getCoded().getUuid(), concept.get("uuid")); Assert.assertEquals(diagnosis.getDiagnosis().getSpecificName().getUuid(), conceptName.get("uuid")); Assert.assertEquals(patient.get("uuid"), diagnosis.getPatient().getUuid()); Assert.assertEquals(originalCount + 1, getAllCount());
diagnosisSource.add("encounter", encounter.getUuid()); diagnosisSource.add("voided", false); diagnosisSource.add("patient", patient.getUuid()); Assert.assertEquals(diagnosis.getVoided(), newDiagnosisSource.get("voided")); Assert.assertEquals(diagnosis.getDiagnosis().getNonCoded(), nonCoded.get("nonCoded")); Assert.assertEquals(patient.get("uuid"), diagnosis.getPatient().getUuid()); Assert.assertEquals(originalCount + 1, getAllCount());
dcOrder.add("type", "testorder"); dcOrder.add("action", "DISCONTINUE"); dcOrder.add("patient", patient.getUuid()); dcOrder.add("concept", orderToDiscontinue.getConcept().getUuid()); dcOrder.add("careSetting", orderToDiscontinue.getCareSetting().getUuid()); assertNotNull(PropertyUtils.getProperty(savedDCOrder, "orderNumber")); assertEquals(dcOrder.get("action"), Util.getByPath(savedDCOrder, "action")); assertEquals(orderToDiscontinue.getPatient().getUuid(), Util.getByPath(savedDCOrder, "patient/uuid")); assertEquals(orderToDiscontinue.getCareSetting().getUuid(), Util.getByPath(savedDCOrder, "careSetting/uuid")); assertEquals(dcOrder.get("previousOrder"), Util.getByPath(savedDCOrder, "previousOrder/uuid"));
revisedOrder.add("action", "REVISE"); revisedOrder.add("previousOrder", orderToRevise.getUuid()); revisedOrder.add("patient", patient.getUuid()); revisedOrder.add("careSetting", orderToRevise.getCareSetting().getUuid()); revisedOrder.add("concept", orderToRevise.getConcept().getUuid()); assertNotNull(PropertyUtils.getProperty(savedOrder, "orderNumber")); assertEquals(revisedOrder.get("action"), Util.getByPath(savedOrder, "action")); assertEquals(patient.getUuid(), Util.getByPath(savedOrder, "patient/uuid")); assertEquals(orderToRevise.getCareSetting().getUuid(), Util.getByPath(savedOrder, "careSetting/uuid")); assertEquals(revisedOrder.get("previousOrder"), Util.getByPath(savedOrder, "previousOrder/uuid"));