Search in sources :

Example 21 with CodeType

use of org.hl7.fhir.dstu2016may.model.CodeType in project elexis-server by elexis.

the class ObservationResourceProvider method filterCode.

private List<Observation> filterCode(List<Observation> observations, CodeType code) {
    ArrayList<Observation> ret = new ArrayList<>();
    String systemString = CodeTypeUtil.getSystem(code).orElse("");
    String codeString = CodeTypeUtil.getCode(code).orElse("");
    for (Observation observation : observations) {
        if (systemString.equals(CodingSystem.ELEXIS_LOCAL_LABORATORY_VITOLABKEY.getSystem())) {
            if (CodeTypeUtil.isVitoLabkey(modelService, observation, codeString)) {
                ret.add(observation);
            }
        } else if (CodeTypeUtil.isCodeInConcept(observation.getCode(), systemString, codeString)) {
            ret.add(observation);
        }
    }
    return ret;
}
Also used : Observation(org.hl7.fhir.r4.model.Observation) IObservation(ch.elexis.core.findings.IObservation) ArrayList(java.util.ArrayList)

Example 22 with CodeType

use of org.hl7.fhir.dstu2016may.model.CodeType in project elexis-server by elexis.

the class MedicationRequestTest method updateMedicationRequest.

@Test
public void updateMedicationRequest() {
    // load existing order
    Bundle results = client.search().forResource(MedicationRequest.class).where(MedicationRequest.PATIENT.hasId(patient.getId())).returnBundle(Bundle.class).execute();
    assertNotNull(results);
    List<BundleEntryComponent> entries = results.getEntry();
    assertFalse(entries.isEmpty());
    Optional<MedicationRequest> activeOrder = getActiveOrderWithDosage(entries);
    assertTrue(activeOrder.isPresent());
    MedicationRequest updateOrder = activeOrder.get();
    updateOrder.getDosageInstruction().get(0).setText("test");
    List<Extension> entryTypes = updateOrder.getExtensionsByUrl("www.elexis.info/extensions/prescription/entrytype");
    assertEquals(EntryType.FIXED_MEDICATION.name(), ((CodeType) entryTypes.get(0).getValue()).getValue());
    entryTypes.get(0).setValue(new CodeType(EntryType.SYMPTOMATIC_MEDICATION.name()));
    // update the medication
    MethodOutcome outcome = client.update().resource(updateOrder).execute();
    // read and validate change
    MedicationRequest oldOrder = client.read().resource(MedicationRequest.class).withId(activeOrder.get().getId()).execute();
    assertNotNull(oldOrder);
    MedicationRequest newOrder = client.read().resource(MedicationRequest.class).withId(outcome.getId()).execute();
    assertNotNull(newOrder);
    assertEquals(MedicationRequestStatus.COMPLETED, oldOrder.getStatus());
    assertEquals(MedicationRequestStatus.ACTIVE, newOrder.getStatus());
    assertEquals("test", newOrder.getDosageInstruction().get(0).getText());
    entryTypes = newOrder.getExtensionsByUrl("www.elexis.info/extensions/prescription/entrytype");
    assertEquals(EntryType.SYMPTOMATIC_MEDICATION.name(), ((CodeType) entryTypes.get(0).getValue()).getValue());
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) CodeType(org.hl7.fhir.r4.model.CodeType) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Test(org.junit.Test)

Example 23 with CodeType

use of org.hl7.fhir.dstu2016may.model.CodeType in project ab2d by CMSgov.

the class CapabilityStatementR4 method populateCS.

public static CapabilityStatement populateCS(String server) {
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    CapabilityStatement cs = new CapabilityStatement();
    cs.setPublisher("Centers for Medicare &amp; Medicaid Services");
    cs.setKind(CapabilityStatement.CapabilityStatementKind.REQUIREMENTS);
    cs.setStatus(Enumerations.PublicationStatus.DRAFT);
    try {
        Date lastUpdated = sdf.parse("02/22/2020 00:00:00");
        cs.setDate(lastUpdated);
    } catch (Exception ex) {
        cs.setDate(new Date());
    }
    cs.setFhirVersion(Enumerations.FHIRVersion._4_0_0);
    cs.setPurpose("Defines FHIR R4 (V2) version of AB2D bulk data download");
    CodeType codeType = new CodeType();
    codeType.setValue(APPLICATION_JSON);
    CodeType codeType2 = new CodeType();
    codeType2.setValue("application/fhir+json");
    cs.setFormat(List.of(codeType, codeType2));
    CapabilityStatement.CapabilityStatementSoftwareComponent cssc = new CapabilityStatement.CapabilityStatementSoftwareComponent();
    cssc.setName("AB2D");
    cssc.setVersion("V2");
    try {
        Date releaseDate = sdf.parse("05/01/2020 00:00:00");
        cssc.setReleaseDate(releaseDate);
    } catch (Exception ex) {
        cssc.setReleaseDate(new Date());
    }
    cs.setSoftware(cssc);
    CapabilityStatement.CapabilityStatementImplementationComponent implementation = new CapabilityStatement.CapabilityStatementImplementationComponent();
    implementation.setDescription("AB2D FHIR R4 Bulk Data Download Implementation");
    implementation.setUrl(server);
    cs.setImplementation(implementation);
    CapabilityStatement.CapabilityStatementRestComponent rest = new CapabilityStatement.CapabilityStatementRestComponent();
    rest.setMode(CapabilityStatement.RestfulCapabilityMode.SERVER);
    CapabilityStatement.CapabilityStatementRestSecurityComponent security = new CapabilityStatement.CapabilityStatementRestSecurityComponent();
    security.setCors(true);
    CodeableConcept codeableConcept = new CodeableConcept();
    Coding coding = new Coding();
    coding.setSystem("http://hl7.org/fhir/ValueSet/restful-security-service");
    coding.setCode("OAuth");
    coding.setDisplay("OAuth");
    codeableConcept.setCoding(List.of(coding));
    codeableConcept.setText("OAuth");
    security.setService(List.of(codeableConcept));
    rest.setSecurity(security);
    List<CapabilityStatement.CapabilityStatementRestResourceOperationComponent> restComponents = new ArrayList<>();
    restComponents.add(createOperation("export", server + "/Patient/$export"));
    restComponents.add(createOperation("export by contract", server + "/Group/{contractNumber}/$export"));
    restComponents.add(createOperation("cancel", server + "/Job/{jobUuid}/$status"));
    restComponents.add(createOperation("status", server + "/Job/{jobUuid}/$status"));
    restComponents.add(createOperation("download", server + "/Job/{jobUuid}/file/{filename}"));
    restComponents.add(createOperation("capability", server + "/metadata"));
    rest.setOperation(restComponents);
    rest.setInteraction(List.of(new CapabilityStatement.SystemInteractionComponent().setCode(CapabilityStatement.SystemRestfulInteraction.BATCH)));
    cs.setRest(List.of(rest));
    return cs;
}
Also used : ArrayList(java.util.ArrayList) Date(java.util.Date) Coding(org.hl7.fhir.r4.model.Coding) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) CodeType(org.hl7.fhir.r4.model.CodeType) SimpleDateFormat(java.text.SimpleDateFormat) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 24 with CodeType

use of org.hl7.fhir.dstu2016may.model.CodeType in project org.hl7.fhir.core by hapifhir.

the class Questionnaire10_50 method convertQuestionnaire.

public static org.hl7.fhir.dstu2.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r5.model.Questionnaire src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.dstu2.model.Questionnaire tgt = new org.hl7.fhir.dstu2.model.Questionnaire();
    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(Identifier10_50.convertIdentifier(t));
    if (src.hasVersionElement())
        tgt.setVersionElement(String10_50.convertString(src.getVersionElement()));
    if (src.hasStatus())
        tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement()));
    if (src.hasDate())
        tgt.setDateElement(DateTime10_50.convertDateTime(src.getDateElement()));
    if (src.hasPublisherElement())
        tgt.setPublisherElement(String10_50.convertString(src.getPublisherElement()));
    for (ContactDetail t : src.getContact()) for (org.hl7.fhir.r5.model.ContactPoint t1 : t.getTelecom()) tgt.addTelecom(ContactPoint10_50.convertContactPoint(t1));
    org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = tgt.getGroup();
    root.setTitle(src.getTitle());
    for (org.hl7.fhir.r5.model.Coding t : src.getCode()) {
        root.addConcept(Coding10_50.convertCoding(t));
    }
    for (CodeType t : src.getSubjectType()) tgt.addSubjectType(t.getValue());
    for (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent t : src.getItem()) if (t.getType() == org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.GROUP)
        root.addGroup(convertQuestionnaireGroupComponent(t));
    else
        root.addQuestion(convertQuestionnaireQuestionComponent(t));
    return tgt;
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) CodeType(org.hl7.fhir.r5.model.CodeType)

Example 25 with CodeType

use of org.hl7.fhir.dstu2016may.model.CodeType in project org.hl7.fhir.core by hapifhir.

the class Questionnaire10_50 method convertQuestionnaireQuestionType.

public static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType> convertQuestionnaireQuestionType(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat> src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemTypeEnumFactory());
    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
    tgt.addExtension(VersionConvertorConstants.EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL, new CodeType(src.getValueAsString()));
    switch(src.getValue()) {
        case BOOLEAN:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.BOOLEAN);
            break;
        case DECIMAL:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DECIMAL);
            break;
        case INTEGER:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.INTEGER);
            break;
        case DATE:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DATE);
            break;
        case DATETIME:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DATETIME);
            break;
        case INSTANT:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DATETIME);
            break;
        case TIME:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.TIME);
            break;
        case STRING:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.STRING);
            break;
        case TEXT:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.TEXT);
            break;
        case URL:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.URL);
            break;
        case CHOICE:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.CODING);
            break;
        case OPENCHOICE:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.CODING);
            break;
        case ATTACHMENT:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.ATTACHMENT);
            break;
        case REFERENCE:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.REFERENCE);
            break;
        case QUANTITY:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.QUANTITY);
            break;
        default:
            tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.NULL);
            break;
    }
    return tgt;
}
Also used : CodeType(org.hl7.fhir.r5.model.CodeType)

Aggregations

CodeType (org.hl7.fhir.r5.model.CodeType)52 ArrayList (java.util.ArrayList)31 CodeType (org.hl7.fhir.r4.model.CodeType)28 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)20 FHIRException (org.hl7.fhir.exceptions.FHIRException)18 CodeType (org.hl7.fhir.r4b.model.CodeType)17 Date (java.util.Date)15 CodeType (org.hl7.fhir.dstu3.model.CodeType)15 NotImplementedException (org.apache.commons.lang3.NotImplementedException)12 File (java.io.File)11 Extension (org.hl7.fhir.dstu3.model.Extension)10 XmlParser (org.hl7.fhir.r5.formats.XmlParser)10 StringType (org.hl7.fhir.r5.model.StringType)10 ValueSet (org.hl7.fhir.r5.model.ValueSet)10 Coding (org.hl7.fhir.r4.model.Coding)9 Coding (org.hl7.fhir.dstu3.model.Coding)8 FileOutputStream (java.io.FileOutputStream)7 List (java.util.List)7 Parameters (org.hl7.fhir.r4.model.Parameters)7 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)7