public OrderBuilder() { patientService = Context.getPatientService(); conceptService = Context.getConceptService(); orderService = Context.getOrderService(); encounterService = Context.getEncounterService(); order = new Order(); }
/** * Prevents regression after patch from #2174: * "Prevent duplicate proxies and AOP in context services" * * @see Context#getService(Class) */ @Test public void getService_shouldReturnTheSameObjectWhenCalledMultipleTimesForTheSameClass() { PatientService ps1 = Context.getService(PatientService.class); PatientService ps2 = Context.getService(PatientService.class); Assert.assertTrue(ps1 == ps2); }
@Before public void runBeforeEachTest() { executeDataSet(CREATE_PATIENT_PROGRAMS_XML); executeDataSet(PROGRAM_ATTRIBUTES_XML); if (pws == null) { pws = Context.getProgramWorkflowService(); adminService = Context.getAdministrationService(); encounterService = Context.getEncounterService(); cs = Context.getConceptService(); } }
/** * @see AdministrationService#getSearchLocales() */ @Override @Transactional(readOnly = true) public List<Locale> getSearchLocales(){ //call it via interface, so cache interceptor is invoked return Context.getAdministrationService().getSearchLocales(Context.getLocale(), Context.getAuthenticatedUser()); }
@Override public Concept getNonCodedDrugConcept() { String conceptUuid = Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GP_DRUG_ORDER_DRUG_OTHER); if (StringUtils.hasText(conceptUuid)) { return Context.getConceptService().getConceptByUuid(conceptUuid); } return null; }
private void validateModuleConfigVersion(String version, File moduleFile) { if (!validConfigVersions.contains(version)) { throw new ModuleException(Context.getMessageSourceService().getMessage("Module.error.invalidConfigVersion", new Object[] { version, String.join(", ", validConfigVersions) }, Context.getLocale()), moduleFile.getName()); } }
@Override protected Concept getObjectByUuid(String uuid) { return Context.getConceptService().getConceptByUuid(uuid); } }
@Before public void onSetUpInTransaction() { if (ps == null) { ps = Context.getPatientService(); adminService = Context.getAdministrationService(); personService = Context.getPersonService(); } }
@Override protected EncounterType getObjectByUuid(String uuid) { return Context.getEncounterService().getEncounterTypeByUuid(uuid); } }
@Test(expected = APIException.class) public void getActiveEncounterVisitHandler_shouldThrowIfBeanWithGivenTypeAndNameNotFound() { String incorrectBeanName = OpenmrsConstants.REGISTERED_COMPONENT_NAME_PREFIX + "invalidName"; GlobalProperty visitHandlerProperty = new GlobalProperty(OpenmrsConstants.GP_VISIT_ASSIGNMENT_HANDLER, incorrectBeanName); Context.getAdministrationService().saveGlobalProperty(visitHandlerProperty); Context.getEncounterService().getActiveEncounterVisitHandler(); }
/** * Gets the simple datetime format for the current user's locale. The format will be similar to * mm/dd/yyyy hh:mm a * * @return SimpleDateFormat for the user's current locale * @see org.openmrs.util.OpenmrsUtil#getDateTimeFormat(Locale) * @should return a pattern with four y characters and two h characters in it */ public static SimpleDateFormat getDateTimeFormat() { return OpenmrsUtil.getDateTimeFormat(getLocale()); }
/** * @see OrderService#getOrderHistoryByConcept(Patient, Concept) */ @Test public void getOrderHistoryByConcept_shouldReturnEmptyListForConceptWithoutOrders() { Concept concept = Context.getConceptService().getConcept(21); Patient patient = Context.getPatientService().getPatient(2); List<Order> orders = orderService.getOrderHistoryByConcept(patient, concept); Assert.assertEquals(0, orders.size()); }
/** * @see PatientService#getPatientByExample(Patient) */ @Test public void getPatientByExample_shouldNotFetchPatientMatchingAnyOtherPatientInformation() throws Exception { Patient examplePatient = Context.getPatientService().getPatient(6); // TODO Test this - it shouldn't matter what the identifier is examplePatient.setId(null); Patient patient = Context.getPatientService().getPatientByExample(examplePatient); Assert.assertNull(patient); }
@Override protected ProgramWorkflow getObjectByUuid(String uuid) { return Context.getProgramWorkflowService().getWorkflowByUuid(uuid); } }
@Override protected PersonAttribute getObjectByUuid(String uuid) { return Context.getPersonService().getPersonAttributeByUuid(uuid); } }
/** * @see PatientService#getPatients(String) */ @Test public void getPatients_shouldForceSearchStringToBeGreaterThanMinsearchcharactersGlobalProperty() throws Exception { // make sure we can get patients with the default of 3 assertEquals(1, Context.getPatientService().getPatients("Colle").size()); Context.clearSession(); Context.getAdministrationService().saveGlobalProperty( new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MIN_SEARCH_CHARACTERS, "4")); assertEquals(0, Context.getPatientService().getPatients("Col").size()); }
/** * @see AuditableInterceptor#onSave(Object,Serializable,Object[],String[],Type[]) */ @Test public void onSave_shouldBeCalledWhenSavingOpenmrsObject() { User u = new User(); u.setSystemId("user"); u.setPerson(Context.getPersonService().getPerson(1)); Context.getUserService().createUser(u, "Admin123"); Assert.assertSame(Context.getAuthenticatedUser(), u.getCreator()); Assert.assertNotNull(u.getDateCreated()); }
/** * @see org.openmrs.api.OrderNumberGenerator#getNewOrderNumber(org.openmrs.api.OrderContext) * @param orderContext */ @Override public String getNewOrderNumber(OrderContext orderContext) throws APIException { return ORDER_NUMBER_PREFIX + Context.getOrderService().getNextOrderNumberSeedSequenceValue(); }
private Map<String, Object> getPropertyValuesToUpdate() { Map<String, Object> propertyValues = new HashMap<>(); propertyValues.put("changedBy", Context.getAuthenticatedUser()); propertyValues.put("dateChanged", new Date()); propertyValues.put("personChangedBy", Context.getAuthenticatedUser()); propertyValues.put("personDateChanged", new Date()); return propertyValues; }
/** * @see EncounterService#getEncountersNotAssignedToAnyVisit(Patient) */ @Test public void getEncountersNotAssignedToAnyVisit_shouldReturnTheUnvoidedEncountersNotAssignedToAnyVisit() { executeDataSet(UNIQUE_ENC_WITH_PAGING_XML); List<Encounter> encs = Context.getEncounterService().getEncountersNotAssignedToAnyVisit( Context.getPatientService().getPatient(10)); Assert.assertEquals(2, encs.size()); Assert.assertNull(encs.get(0).getVisit()); Assert.assertNull(encs.get(1).getVisit()); }