Search in sources :

Example 1 with ENTEREDINERROR

use of org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.ENTEREDINERROR in project org.hl7.fhir.core by hapifhir.

the class MedicationKnowledge40_50 method convertMedicationKnowledgeStatus.

private static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationKnowledge.MedicationKnowledgeStatusCodes> convertMedicationKnowledgeStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MedicationKnowledge.MedicationKnowledgeStatus> src) {
    if (src == null)
        return null;
    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationKnowledge.MedicationKnowledgeStatusCodes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new MedicationKnowledgeStatusCodesEnumFactory());
    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
    switch(src.getValue()) {
        case ACTIVE:
            tgt.setValue(org.hl7.fhir.r5.model.MedicationKnowledge.MedicationKnowledgeStatusCodes.ACTIVE);
            break;
        case ENTEREDINERROR:
            tgt.setValue(org.hl7.fhir.r5.model.MedicationKnowledge.MedicationKnowledgeStatusCodes.ENTEREDINERROR);
            break;
        case INACTIVE:
            tgt.setValue(org.hl7.fhir.r5.model.MedicationKnowledge.MedicationKnowledgeStatusCodes.INACTIVE);
            break;
        case NULL:
            tgt.setValue(org.hl7.fhir.r5.model.MedicationKnowledge.MedicationKnowledgeStatusCodes.NULL);
            break;
    }
    return tgt;
}
Also used : MedicationKnowledgeStatusCodesEnumFactory(org.hl7.fhir.r5.model.MedicationKnowledge.MedicationKnowledgeStatusCodesEnumFactory)

Example 2 with ENTEREDINERROR

use of org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.ENTEREDINERROR in project BridgeServer2 by Sage-Bionetworks.

the class CRCControllerTest method postAppointmentMistakeRollsBackAccount.

@Test
public void postAppointmentMistakeRollsBackAccount() throws Exception {
    when(mockRequest.getHeader(AUTHORIZATION)).thenReturn(AUTHORIZATION_HEADER_VALUE);
    when(mockAccountService.authenticate(any(), any())).thenReturn(account);
    when(mockAccountService.getAccount(ACCOUNT_ID)).thenReturn(Optional.of(account));
    Appointment appointment = new Appointment();
    appointment.setStatus(ENTEREDINERROR);
    addAppointmentParticipantComponent(appointment, LOCATION_NS + "foo");
    addAppointmentSageId(appointment, TEST_USER_ID);
    String json = FHIR_CONTEXT.newJsonParser().encodeResourceToString(appointment);
    mockRequestBody(mockRequest, json);
    ResponseEntity<StatusMessage> retValue = controller.postAppointment();
    assertEquals(retValue.getBody().getMessage(), "Appointment deleted.");
    assertEquals(retValue.getStatusCodeValue(), 200);
    assertTrue(account.getDataGroups().contains("selected"));
    verify(mockAccountService).updateAccount(account);
    verify(mockReportService).deleteParticipantReportRecord(APP_ID, TEST_USER_ID, APPOINTMENT_REPORT, JAN1.toString(), HEALTH_CODE);
}
Also used : Appointment(org.hl7.fhir.dstu3.model.Appointment) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) Test(org.testng.annotations.Test)

Example 3 with ENTEREDINERROR

use of org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.ENTEREDINERROR in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7MedicationRequestFHIRConversionTest method test_medicationreq_status.

@Test
void test_medicationreq_status() {
    // ORC.5 = A -> Expected medication status = (ACTIVE ORC.1 is present but ORC.5 takes precedence)
    String hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX||A|E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.ACTIVE);
    // ORC.5 = CM -> Expected medication status = COMPLETED (ORC.1 is present but ORC.5 takes precedence)
    hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX||CM|E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
    e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    medicationRequestList.clear();
    medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.COMPLETED);
    // ORC.5 = ER -> Expected medication status = ENTEREDINERROR (ORC.1 is present but ORC.5 takes precedence)
    hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX||ER|E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
    e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    medicationRequestList.clear();
    medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.ENTEREDINERROR);
    // ORC.1 = NW -> Expected medication status = ACTIVE (Missing ORC.5 so ORC.1 takes precedence)
    hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
    e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    medicationRequestList.clear();
    medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.ACTIVE);
    // ORC.1 = RP -> Expected medication status = UNKNOWN (Missing ORC.5 so ORC.1 takes precedence)
    hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|RP|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
    e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    medicationRequestList.clear();
    medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.UNKNOWN);
    // ORC.1 = DC -> Expected medication status = STOPPED (Missing ORC.5 so ORC.1 takes precedence)
    hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|DC|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
    e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    medicationRequestList.clear();
    medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.STOPPED);
    // Test that RDE_O11 messages don't create ServiceRequests
    List<Resource> serviceRequestList = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    // Confirm that a serviceRequest was not created.
    assertThat(serviceRequestList).isEmpty();
    // ORC.1 = CA -> Expected medication status = CANCELLED (Missing ORC.5 so ORC.1 takes precedence)
    hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I|6N^1234^A^GENHOS||||0100^ANDERSON,CARL|0148^ADDISON,JAMES||SUR|||||||0100^ANDERSON,CARL|S|V446911|A|||||||||||||||||||SF|K||||20180622230000\n" + "ORC|CA|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
    e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    medicationRequestList.clear();
    medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.CANCELLED);
    // Test that RDE_O11 messages don't create ServiceRequests
    serviceRequestList.clear();
    serviceRequestList = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    // Confirm that a serviceRequest was not created.
    assertThat(serviceRequestList).isEmpty();
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Identifier(org.hl7.fhir.r4.model.Identifier) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Range(org.hl7.fhir.r4.model.Range) Calendar(java.util.Calendar) HumanName(org.hl7.fhir.r4.model.HumanName) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) ConverterConfiguration(io.github.linuxforhealth.core.config.ConverterConfiguration) ResourceUtils(io.github.linuxforhealth.hl7.segments.util.ResourceUtils) Quantity(org.hl7.fhir.r4.model.Quantity) Ratio(org.hl7.fhir.r4.model.Ratio) HL7ToFHIRConverter(io.github.linuxforhealth.hl7.HL7ToFHIRConverter) Patient(org.hl7.fhir.r4.model.Patient) Practitioner(org.hl7.fhir.r4.model.Practitioner) ValueSource(org.junit.jupiter.params.provider.ValueSource) TimeZone(java.util.TimeZone) Resource(org.hl7.fhir.r4.model.Resource) MedicationRequestStatus(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) Test(org.junit.jupiter.api.Test) ResourceType(org.hl7.fhir.r4.model.ResourceType) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DatatypeUtils(io.github.linuxforhealth.hl7.segments.util.DatatypeUtils) Extension(org.hl7.fhir.r4.model.Extension) MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with ENTEREDINERROR

use of org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.ENTEREDINERROR in project BridgeServer2 by Sage-Bionetworks.

the class CRCController method postAppointment.

@PutMapping("/v1/cuimc/appointments")
public ResponseEntity<StatusMessage> postAppointment() {
    App app = httpBasicAuthentication();
    IParser parser = FHIR_CONTEXT.newJsonParser();
    JsonNode data = parseJson(JsonNode.class);
    Appointment appointment = parser.parseResource(Appointment.class, data.toString());
    String userId = findUserId(appointment);
    // They send appointment when it is booked, cancelled, or (rarely) enteredinerror.
    AccountStates state = TESTS_SCHEDULED;
    String apptStatus = data.get("status").asText();
    if ("entered-in-error".equals(apptStatus)) {
        deleteReportAndUpdateState(app, userId);
        return ResponseEntity.ok(new StatusMessage("Appointment deleted."));
    } else if ("cancelled".equals(apptStatus)) {
        state = TESTS_CANCELLED;
    }
    // Columbia wants us to call back to them to get information about the location.
    // And UI team wants geocoding of location to render a map.
    String locationString = findLocation(appointment);
    if (locationString != null) {
        AccountId accountId = parseAccountId(app.getIdentifier(), userId);
        Account account = accountService.getAccount(accountId).orElseThrow(() -> new EntityNotFoundException(Account.class));
        addLocation(data, account, locationString);
    }
    int status = writeReportAndUpdateState(app, userId, data, APPOINTMENT_REPORT, state, true);
    if (status == 200) {
        return ResponseEntity.ok(new StatusMessage("Appointment updated (status = " + apptStatus + ")."));
    }
    return ResponseEntity.created(URI.create("/v1/cuimc/appointments/" + userId)).body(new StatusMessage("Appointment created (status = " + apptStatus + ")."));
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) Appointment(org.hl7.fhir.dstu3.model.Appointment) Account(org.sagebionetworks.bridge.models.accounts.Account) BridgeUtils.parseAccountId(org.sagebionetworks.bridge.BridgeUtils.parseAccountId) AccountId(org.sagebionetworks.bridge.models.accounts.AccountId) JsonNode(com.fasterxml.jackson.databind.JsonNode) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) IParser(ca.uhn.fhir.parser.IParser) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 5 with ENTEREDINERROR

use of org.hl7.fhir.dstu3.model.Appointment.AppointmentStatus.ENTEREDINERROR in project org.hl7.fhir.core by hapifhir.

the class MedicationDispense10_50 method convertMedicationDispenseStatus.

public static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes> convertMedicationDispenseStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.MedicationDispense.MedicationDispenseStatus> src) throws FHIRException {
    if (src == null)
        return null;
    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new MedicationDispenseStatusCodesEnumFactory());
    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
    switch(src.getValue()) {
        case COMPLETED:
            tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.COMPLETED);
            break;
        case ENTEREDINERROR:
            tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.ENTEREDINERROR);
            break;
        case INPROGRESS:
            tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.INPROGRESS);
            break;
        case NULL:
            tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.NULL);
            break;
        case ONHOLD:
            tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.ONHOLD);
            break;
        case STOPPED:
            tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.STOPPED);
            break;
    }
    return tgt;
}
Also used : MedicationDispenseStatusCodesEnumFactory(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodesEnumFactory)

Aggregations

Appointment (org.hl7.fhir.dstu3.model.Appointment)2 MedicationDispenseStatusCodesEnumFactory (org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodesEnumFactory)2 StatusMessage (org.sagebionetworks.bridge.models.StatusMessage)2 IParser (ca.uhn.fhir.parser.IParser)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ConverterConfiguration (io.github.linuxforhealth.core.config.ConverterConfiguration)1 HL7ToFHIRConverter (io.github.linuxforhealth.hl7.HL7ToFHIRConverter)1 DatatypeUtils (io.github.linuxforhealth.hl7.segments.util.DatatypeUtils)1 ResourceUtils (io.github.linuxforhealth.hl7.segments.util.ResourceUtils)1 ZoneId (java.time.ZoneId)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 List (java.util.List)1 TimeZone (java.util.TimeZone)1 Collectors (java.util.stream.Collectors)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)1 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)1 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Extension (org.hl7.fhir.r4.model.Extension)1