Search in sources :

Example 1 with AdtService

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");
}
Also used : DispositionService(org.openmrs.module.emrapi.disposition.DispositionService) AdtService(org.openmrs.module.emrapi.adt.AdtService) HtmlFormEntryService(org.openmrs.module.htmlformentry.HtmlFormEntryService) EmrApiProperties(org.openmrs.module.emrapi.EmrApiProperties) EncounterDiagnosesTagHandler(org.openmrs.module.coreapps.htmlformentry.EncounterDiagnosesTagHandler) ConceptService(org.openmrs.api.ConceptService) EncounterDispositionTagHandler(org.openmrs.module.coreapps.htmlformentry.EncounterDispositionTagHandler) CodedOrFreeTextObsTagHandler(org.openmrs.module.coreapps.htmlformentry.CodedOrFreeTextObsTagHandler) BasicUiUtils(org.openmrs.ui.framework.BasicUiUtils) UiUtils(org.openmrs.ui.framework.UiUtils)

Example 2 with AdtService

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);
        }
    }
}
Also used : Appointment(org.openmrs.module.appointmentscheduling.Appointment) AdtService(org.openmrs.module.emrapi.adt.AdtService) Date(java.util.Date) DateTime(org.joda.time.DateTime) AppointmentService(org.openmrs.module.appointmentscheduling.api.AppointmentService)

Example 3 with AdtService

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);
            }
        }
    }
}
Also used : LocationTag(org.openmrs.LocationTag) AdtService(org.openmrs.module.emrapi.adt.AdtService) LocationService(org.openmrs.api.LocationService) VisitService(org.openmrs.api.VisitService) Visit(org.openmrs.Visit) Location(org.openmrs.Location)

Aggregations

AdtService (org.openmrs.module.emrapi.adt.AdtService)3 Date (java.util.Date)1 DateTime (org.joda.time.DateTime)1 Location (org.openmrs.Location)1 LocationTag (org.openmrs.LocationTag)1 Visit (org.openmrs.Visit)1 ConceptService (org.openmrs.api.ConceptService)1 LocationService (org.openmrs.api.LocationService)1 VisitService (org.openmrs.api.VisitService)1 Appointment (org.openmrs.module.appointmentscheduling.Appointment)1 AppointmentService (org.openmrs.module.appointmentscheduling.api.AppointmentService)1 CodedOrFreeTextObsTagHandler (org.openmrs.module.coreapps.htmlformentry.CodedOrFreeTextObsTagHandler)1 EncounterDiagnosesTagHandler (org.openmrs.module.coreapps.htmlformentry.EncounterDiagnosesTagHandler)1 EncounterDispositionTagHandler (org.openmrs.module.coreapps.htmlformentry.EncounterDispositionTagHandler)1 EmrApiProperties (org.openmrs.module.emrapi.EmrApiProperties)1 DispositionService (org.openmrs.module.emrapi.disposition.DispositionService)1 HtmlFormEntryService (org.openmrs.module.htmlformentry.HtmlFormEntryService)1 BasicUiUtils (org.openmrs.ui.framework.BasicUiUtils)1 UiUtils (org.openmrs.ui.framework.UiUtils)1