use of org.openmrs.module.emrapi.adt.AdtService in project openmrs-module-coreapps by openmrs.
the class CoreAppsActivator method contextRefreshed.
/**
* @see ModuleActivator#contextRefreshed()
*/
public void contextRefreshed() {
ConceptService conceptService = Context.getConceptService();
EmrApiProperties emrApiProperties = Context.getRegisteredComponent("emrApiProperties", EmrApiProperties.class);
DispositionService dispositionService = Context.getRegisteredComponent("dispositionService", DispositionService.class);
AdtService adtService = Context.getRegisteredComponent("adtService", AdtService.class);
UiUtils uiUtils = Context.getRegisteredComponent("uiUtils", BasicUiUtils.class);
if (ModuleFactory.isModuleStarted("htmlformentry")) {
HtmlFormEntryService htmlFormEntryService = Context.getService(HtmlFormEntryService.class);
EncounterDiagnosesTagHandler encounterDiagnosesTagHandler = CoreAppsActivator.setupEncounterDiagnosesTagHandler(conceptService, adtService, emrApiProperties, uiUtils);
htmlFormEntryService.addHandler(CoreAppsConstants.HTMLFORMENTRY_ENCOUNTER_DIAGNOSES_TAG_NAME, encounterDiagnosesTagHandler);
EncounterDispositionTagHandler encounterDispositionTagHandler = CoreAppsActivator.setupEncounterDispositionTagHandler(emrApiProperties, dispositionService, adtService);
htmlFormEntryService.addHandler(CoreAppsConstants.HTMLFORMENTRY_ENCOUNTER_DISPOSITION_TAG_NAME, encounterDispositionTagHandler);
htmlFormEntryService.addHandler(CoreAppsConstants.HTMLFORMENTRY_CODED_OR_FREE_TEXT_OBS_TAG_NAME, new CodedOrFreeTextObsTagHandler());
}
log.info("Core Apps Module refreshed");
}
use of org.openmrs.module.emrapi.adt.AdtService in project openmrs-module-mirebalais by PIH.
the class MarkAppointmentsAsMissedOrCompletedTask method execute.
@Override
public void execute() {
AppointmentService appointmentService = Context.getService(AppointmentService.class);
AdtService adtService = Context.getService(AdtService.class);
Date endOfYesterday = new DateTime().withTime(23, 59, 59, 999).minusDays(1).toDate();
for (Appointment appointment : appointmentService.getAppointmentsByConstraints(null, endOfYesterday, null, null, null, null, Appointment.AppointmentStatus.getAppointmentsStatusByTypes(Arrays.asList(Appointment.AppointmentStatusType.SCHEDULED)))) {
appointment.setStatus(Appointment.AppointmentStatus.MISSED);
appointmentService.saveAppointment(appointment);
}
for (Appointment appointment : appointmentService.getAppointmentsByConstraints(null, endOfYesterday, null, null, null, null, Appointment.AppointmentStatus.getAppointmentsStatusByTypes(Arrays.asList(Appointment.AppointmentStatusType.ACTIVE)))) {
if (appointment.getVisit() != null && adtService.wrap(appointment.getVisit()).hasVisitNoteAtLocation(appointment.getTimeSlot().getAppointmentBlock().getLocation())) {
appointment.setStatus(Appointment.AppointmentStatus.COMPLETED);
appointmentService.saveAppointment(appointment);
}
}
}
use of org.openmrs.module.emrapi.adt.AdtService in project openmrs-module-pihcore by PIH.
the class PihCloseStaleVisitsTask method execute.
public void execute() {
AdtService adtService = Context.getService(AdtService.class);
VisitService visitService = Context.getVisitService();
LocationService locationService = Context.getLocationService();
LocationTag visitLocationTag = locationService.getLocationTagByName(EmrApiConstants.LOCATION_TAG_SUPPORTS_VISITS);
List<Location> locations = locationService.getLocationsByTag(visitLocationTag);
List<Visit> openVisits = visitService.getVisits(null, null, locations, null, null, null, null, null, null, false, false);
for (Visit visit : openVisits) {
if ((isOldEDVisit(adtService.wrap(visit), ED_VISIT_EXPIRE_VERY_OLD_TIME_IN_HOURS)) || (adtService.shouldBeClosed(visit) && !isActiveEDVisit(adtService.wrap(visit), ED_VISIT_EXPIRE_TIME_IN_HOURS)) || wasDischargedAndNotAdmitted(adtService.wrap(visit), HUM_VISIT_EXPIRE_TIME_IN_HOURS)) {
try {
adtService.closeAndSaveVisit(visit);
} catch (Exception ex) {
log.warn("Failed to close inactive visit " + visit, ex);
}
}
}
}
Aggregations