/** * Convenient method that safely checks if user has given encounter privilege * * @param privilege the privilege to test * @param user the user instance to check if it has given privilege * @return true if given user has specified privilege */ private boolean userHasEncounterPrivilege(Privilege privilege, User user) { // If the encounter privilege is null, everyone can see and edit the encounter. if (privilege == null) { return true; } return user.hasPrivilege(privilege.getPrivilege()); }
public void addMetadata() { { EncounterType et = Context.getEncounterService().getEncounterType("Registration"); if (et == null) et = Context.getEncounterService() .getEncounterTypeByUuid("cfe614d5-fa7e-4919-b76b-a66117f57e4c"); if (et == null) { et = new EncounterType("Registration", "Patient seen at registration desk"); et.setUuid("cfe614d5-fa7e-4919-b76b-a66117f57e4c"); Context.getEncounterService().saveEncounterType(et); log.info("Created new Registration encounter type: " + et); } PrimaryCareConstants.ENCOUNTER_TYPE_REGISTRATION = et; } { EncounterType et = Context.getEncounterService().getEncounterType("Vitals"); if (et == null) et = Context.getEncounterService() .getEncounterTypeByUuid("daf32375-d293-4e27-a68d-2a58494c96e1"); if (et == null) { et = new EncounterType("Vitals", "Patient vital signs taken before seeing clinician"); et.setUuid("daf32375-d293-4e27-a68d-2a58494c96e1"); Context.getEncounterService().saveEncounterType(et); log.info("Created new Vitals encounter type: " + et); } PrimaryCareConstants.ENCOUNTER_TYPE_VITALS = et; } { EncounterType et = Context.getEncounterService().getEncounterType("Diagnosis"); if (et == null) et = Context.getEncounterService() .getEncounterTypeByUuid("e9355a6e-b2df-44b4-911c-104c6a41ed24"); if (et == null) { et = new EncounterType("Diagnosis", "Diagnosis recorded"); et.setUuid("e9355a6e-b2df-44b4-911c-104c6a41ed24"); Context.getEncounterService().saveEncounterType(et); log.info("Created new Diagnosis encounter type: " + et); } PrimaryCareConstants.ENCOUNTER_TYPE_DIAGNOSIS = et; } { Privilege p = Context.getUserService().getPrivilege("Print Registration Barcodes Offline"); if (p == null) { p = new Privilege( "Print Registration Barcodes Offline", "Allows a user to print registration barcodes offline."); p.setRetired(false); p.setUuid("c733a17e-bf39-4aba-a1b4-06aa013b7c49"); Context.getUserService().savePrivilege(p); log.info("Created new Privilege" + p.getPrivilege()); } PrimaryCareConstants.PRINT_BARCODE_OFFLINE_PRIVILEGE = p; } { Privilege p = Context.getUserService().getPrivilege("Generate Bulk Primary Care Ids All Locations"); if (p == null) { p = new Privilege( "Generate Bulk Primary Care Ids All Locations", "Allows a user to generate a csv of primary care ids for any registered location."); p.setRetired(false); p.setUuid("1149b78f-9964-4bf6-ac19-c01a4c268879"); Context.getUserService().savePrivilege(p); log.info("Created new Privilege" + p.getPrivilege()); } PrimaryCareConstants.GENERATE_BULK_PRIMARY_CARE_IDS = p; } { EncounterRole er = Context.getEncounterService() .getEncounterRoleByUuid("e8a0fb6a-aba5-11e1-b9e7-002713655c9f"); if (er == null) { er = new EncounterRole(); er.setDescription( "This role represents primrary care registration during a primary care registration encounter."); er.setName("Primary Care Registration Recorder"); er.setUuid("e8a0fb6a-aba5-11e1-b9e7-002713655c9f"); // this is for openmrs1.9. Awful. er.setCreator( Context.getEncounterService() .getEncounterRoleByUuid(EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID) .getCreator()); er.setDateCreated(new Date()); er.setRetired(false); Context.getEncounterService().saveEncounterRole(er); log.info("Created Encounter Role representing primary care registration"); } PrimaryCareConstants.PRIMARY_CARE_ENCOUNTER_ROLE = er; } { VisitType vt = Context.getVisitService().getVisitTypeByUuid("3515b588-b1df-4110-991b-0d603686d8e6"); if (vt == null) { vt = new VisitType(); vt.setCreator( Context.getEncounterService() .getEncounterRoleByUuid(EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID) .getCreator()); // hack vt.setDateCreated(new Date()); vt.setDescription("Represents a single day primary care visit to a health center."); vt.setName("Primary Care Outpatient"); vt.setRetired(false); vt.setUuid("3515b588-b1df-4110-991b-0d603686d8e6"); vt = Context.getVisitService().saveVisitType(vt); log.info("Created primary care outpatient visit type"); } PrimaryCareConstants.VISIT_TYPE_OUTPATIENT = vt; } }