Search in sources :

Example 56 with PatientIdentifier

use of org.openmrs.PatientIdentifier in project openmrs-module-pihcore by PIH.

the class ZplLabLabelTemplate method getIdentifier.

protected String getIdentifier(Patient patient) {
    PatientIdentifierType idType = emrApiProperties.getPrimaryIdentifierType();
    PatientIdentifier pi = patient.getPatientIdentifier(idType);
    if (pi == null || pi.isVoided()) {
        pi = patient.getPatientIdentifier();
    }
    return pi == null ? "" : pi.getIdentifier();
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) PatientIdentifier(org.openmrs.PatientIdentifier)

Example 57 with PatientIdentifier

use of org.openmrs.PatientIdentifier in project openmrs-module-pihcore by PIH.

the class ZlEmrIdCardPrinter method getIdentifier.

/**
 * @return the patient identifier in the format that it should be displayed on the id cards
 */
protected String getIdentifier(Patient patient) {
    PatientIdentifierType idType = emrApiProperties.getPrimaryIdentifierType();
    PatientIdentifier pi = patient.getPatientIdentifier(idType);
    if (pi == null || pi.isVoided()) {
        pi = patient.getPatientIdentifier();
    }
    return pi == null ? "" : pi.getIdentifier();
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) PatientIdentifier(org.openmrs.PatientIdentifier)

Example 58 with PatientIdentifier

use of org.openmrs.PatientIdentifier in project openmrs-module-pihcore by PIH.

the class AssignDossierNumber method afterPatientCreated.

@Override
public synchronized void afterPatientCreated(Patient patient, Map<String, String[]> map) {
    PatientIdentifierType dossierIdentifierType = patientService.getPatientIdentifierTypeByUuid(ZlConfigConstants.PATIENTIDENTIFIERTYPE_DOSSIERNUMBER_UUID);
    Location medicalRecordLocation = getMedicalRecordLocation();
    String dossierId = "";
    dossierId = identifierSourceService.generateIdentifier(dossierIdentifierType, medicalRecordLocation, "generating a new dossier number");
    // double check to make sure this identifier is not in use--since manual entry is allowed, it could be
    while (dossierIdentifierInUse(dossierId, dossierIdentifierType, medicalRecordLocation)) {
        log.error("Attempted to generate duplicate dossier identifier " + dossierId);
        dossierId = identifierSourceService.generateIdentifier(dossierIdentifierType, medicalRecordLocation, "generating a new dossier number");
    }
    if (StringUtils.isBlank(dossierId)) {
        throw new APIException("Unable to generate dossier number for patient " + patient);
    }
    PatientIdentifier dossierIdentifier = new PatientIdentifier(dossierId, dossierIdentifierType, medicalRecordLocation);
    patient.addIdentifier(dossierIdentifier);
    patientService.savePatientIdentifier(dossierIdentifier);
}
Also used : APIException(org.openmrs.api.APIException) PatientIdentifierType(org.openmrs.PatientIdentifierType) PatientIdentifier(org.openmrs.PatientIdentifier) Location(org.openmrs.Location)

Example 59 with PatientIdentifier

use of org.openmrs.PatientIdentifier in project openmrs-module-pihcore by PIH.

the class IdCardFragmentController method recordSuccessfulPrintAttempt.

/**
 * This method takes in a patientId and an identifier and validates that this is a valid identifier for this patient
 * If it is valid, it will save an Observation to the patient record indicating that an id card was successfully printed
 * @return a SimpleObject containing a flag indicating success, and a message suitable for display
 */
public SimpleObject recordSuccessfulPrintAttempt(UiUtils ui, UiSessionContext uiSessionContext, @SpringBean EmrApiProperties emrApiProperties, @RequestParam("patientId") Patient patient, @RequestParam("identifier") String identifier) {
    StatusMessage status = new StatusMessage(false, ui.message("zl.registration.patient.idcard.invalidForPatient", identifier, ui.format(patient.getPersonName())));
    for (PatientIdentifier pi : patient.getIdentifiers()) {
        if (pi.getIdentifierType().getUuid().equals(emrApiProperties.getPrimaryIdentifierType().getUuid())) {
            if (pi.getIdentifier().equalsIgnoreCase(identifier)) {
                status = new StatusMessage(true, "");
                savePrintingStatusObs(patient, uiSessionContext.getSessionLocation(), true);
            }
        }
    }
    return SimpleObject.fromObject(status, ui, "success", "message");
}
Also used : PatientIdentifier(org.openmrs.PatientIdentifier)

Example 60 with PatientIdentifier

use of org.openmrs.PatientIdentifier in project openmrs-module-mirebalais by PIH.

the class MirthIT method testMirthChannelIntegration.

@Test
@DirtiesContext
public void testMirthChannelIntegration() throws Exception {
    authenticate();
    // if the test patient already exists, delete it and any existing orders
    if (patientService.getPatients("2ADMMN").size() > 0) {
        Patient patient = patientService.getPatients("2ADMMN").get(0);
        for (Order order : orderService.getAllOrdersByPatient(patient)) {
            orderService.purgeOrder(order);
        }
        for (Encounter encounter : encounterService.getEncountersByPatient(patient)) {
            encounterService.purgeEncounter(encounter);
        }
        for (Visit visit : visitService.getVisitsByPatient(patient)) {
            visitService.purgeVisit(visit);
        }
        patientService.purgePatient(patient);
    }
    // TODO: eventually we should make sure all the necessary fields are included here
    // first create and save a patient
    Patient patient = new Patient();
    patient.setGender("M");
    Calendar birthdate = Calendar.getInstance();
    birthdate.set(2000, 2, 23);
    patient.setBirthdate(birthdate.getTime());
    PersonName name = new PersonName();
    name.setFamilyName("Test Patient");
    name.setGivenName("Mirth Integration");
    patient.addName(name);
    PatientIdentifier identifier = new PatientIdentifier();
    identifier.setIdentifierType(emrApiProperties.getPrimaryIdentifierType());
    identifier.setIdentifier("2ADMMN");
    identifier.setPreferred(true);
    identifier.setLocation(locationService.getLocation("Unknown Location"));
    patient.addIdentifier(identifier);
    // save the patient
    patientService.savePatient(patient);
    /**
     *  Commenting this out because we are not currently sending ADT information to APCS
     *		String result = listenForResults();
     *
     *		System.out.println(result);
     *
     *		// make sure the appropriate message has been delivered
     *		TestUtils.assertContains("MSH|^~\\&|||||||ADT^A01||P|2.3", result);
     *		TestUtils.assertContains("PID|||2ADMMN||Test Patient^Mirth Integration||200003230000|M", result);
     *
     *		// now resave the patient and verify that a patient updated message is sent
     *		// save the patient to trigger an update event
     *		patientService.savePatient(patient);
     *
     *		result = listenForResults();
     *
     *		System.out.println(result);
     *
     *		TestUtils.assertContains("MSH|^~\\&|||||||ADT^A08||P|2.3", result);
     *		TestUtils.assertContains("PID|||2ADMMN||Test Patient^Mirth Integration||200003230000|M", result);
     */
    // TODO: eventually we should make sure all the necessary fields are concluded here
    // TODO: specifically: sending facility, device location, universal service id, universal service id text, and modality
    // ensure that there is a visit for the patient (so that the encounter visit handlers doesn't bomb)
    adtService.ensureActiveVisit(patient, locationService.getLocation("Mirebalais Hospital"));
    // now create and save the order for this patient
    RadiologyOrder order = new RadiologyOrder();
    order.setOrderType(orderService.getOrderTypeByUuid(administrationService.getGlobalProperty(RadiologyConstants.GP_RADIOLOGY_TEST_ORDER_TYPE)));
    order.setPatient(patient);
    // chest x-ray, one view
    order.setConcept(conceptService.getConceptByUuid("fc6de1c0-1a36-11e2-a310-aa00f871a3e1"));
    order.setAccessionNumber("ACCESSION NUMBER");
    order.setDateActivated(new SimpleDateFormat("MM-dd-yyyy").parse("09-09-2012"));
    order.setUrgency(Order.Urgency.STAT);
    order.setClinicalHistory("Patient fell off horse");
    order.setExamLocation(locationService.getLocation("Mirebalais Hospital"));
    Encounter encounter = new Encounter();
    encounter.setPatient(patient);
    encounter.setEncounterDatetime(new Date());
    encounter.setLocation(locationService.getLocation("Mirebalais Hospital"));
    encounter.setEncounterType(encounterService.getEncounterType(1));
    encounter.addOrder(order);
    encounter.addProvider(emrApiProperties.getOrderingProviderEncounterRole(), Context.getProviderService().getProvider(1));
    encounterService.saveEncounter(encounter);
// TODO: I've changed the configuration so that this sends the message directly to the PACS test server
// TODO: since we aren't getting messages send back from PACS yet, there is no good way to test this
/*String result = listenForResults();
		
		TestUtils.assertContains("MSH|^~\\&||Mirebalais|||||ORM^O01||P|2.3", result);
		TestUtils.assertContains("PID|||2ADMMN||Test Patient^Mirth Integration||200003230000|M", result);
		TestUtils.assertContains("PV1|||Mirebalais Hospital|||||^User^Super", result);
		TestUtils.assertContains("ORC|NW", result);
		TestUtils
		        .assertContains(
		            "OBR|||ACCESSION NUMBER|36554-4^X-ray of chest, 1 view|||||||||||||||CR||||||||^^^^^STAT||||^Patient fell off horse|||||201209090000",
		            result);*/
}
Also used : RadiologyOrder(org.openmrs.module.radiologyapp.RadiologyOrder) Order(org.openmrs.Order) PersonName(org.openmrs.PersonName) Visit(org.openmrs.Visit) Calendar(java.util.Calendar) RadiologyOrder(org.openmrs.module.radiologyapp.RadiologyOrder) Patient(org.openmrs.Patient) Encounter(org.openmrs.Encounter) SimpleDateFormat(java.text.SimpleDateFormat) PatientIdentifier(org.openmrs.PatientIdentifier) Date(java.util.Date) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Aggregations

PatientIdentifier (org.openmrs.PatientIdentifier)116 Test (org.junit.Test)91 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)74 Patient (org.openmrs.Patient)66 PatientIdentifierType (org.openmrs.PatientIdentifierType)57 PatientServiceImplTest (org.openmrs.api.impl.PatientServiceImplTest)47 Location (org.openmrs.Location)27 PersonName (org.openmrs.PersonName)24 Date (java.util.Date)19 PersonAddress (org.openmrs.PersonAddress)12 ArrayList (java.util.ArrayList)10 BindException (org.springframework.validation.BindException)8 User (org.openmrs.User)7 Errors (org.springframework.validation.Errors)7 SimpleDateFormat (java.text.SimpleDateFormat)5 Person (org.openmrs.Person)5 PatientIdentifierException (org.openmrs.api.PatientIdentifierException)5 HL7Exception (ca.uhn.hl7v2.HL7Exception)3 ApplicationException (ca.uhn.hl7v2.app.ApplicationException)3 CX (ca.uhn.hl7v2.model.v25.datatype.CX)3