Search in sources :

Example 91 with CodeType

use of org.hl7.fhir.r4.model.CodeType in project cqf-ruler by DBCG.

the class MultitenantServerR4IT method testCreateAndReadInTenantA.

@Test
public void testCreateAndReadInTenantA() {
    // Create tenant A
    ourClientTenantInterceptor.setTenantId("DEFAULT");
    ourClient.operation().onServer().named(ProviderConstants.PARTITION_MANAGEMENT_CREATE_PARTITION).withParameter(Parameters.class, ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID, new IntegerType(1)).andParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME, new CodeType("TENANT-A")).execute();
    ourClientTenantInterceptor.setTenantId("TENANT-A");
    Patient pt = new Patient();
    pt.addName().setFamily("Family A");
    ourClient.create().resource(pt).execute().getId();
    Bundle searchResult = ourClient.search().forResource(Patient.class).returnBundle(Bundle.class).cacheControl(new CacheControlDirective().setNoCache(true)).execute();
    assertEquals(1, searchResult.getEntry().size());
    Patient pt2 = (Patient) searchResult.getEntry().get(0).getResource();
    assertEquals("Family A", pt2.getName().get(0).getFamily());
}
Also used : IntegerType(org.hl7.fhir.r4.model.IntegerType) CacheControlDirective(ca.uhn.fhir.rest.api.CacheControlDirective) Bundle(org.hl7.fhir.r4.model.Bundle) CodeType(org.hl7.fhir.r4.model.CodeType) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 92 with CodeType

use of org.hl7.fhir.r4.model.CodeType in project cqf-ruler by DBCG.

the class MultitenantServerR4IT method testCreateAndReadInTenantB.

@Test
public void testCreateAndReadInTenantB() {
    // Create tenant A
    ourClientTenantInterceptor.setTenantId("DEFAULT");
    ourClient.operation().onServer().named(ProviderConstants.PARTITION_MANAGEMENT_CREATE_PARTITION).withParameter(Parameters.class, ProviderConstants.PARTITION_MANAGEMENT_PARTITION_ID, new IntegerType(2)).andParameter(ProviderConstants.PARTITION_MANAGEMENT_PARTITION_NAME, new CodeType("TENANT-B")).execute();
    ourClientTenantInterceptor.setTenantId("TENANT-B");
    Patient pt = new Patient();
    pt.addName().setFamily("Family B");
    ourClient.create().resource(pt).execute().getId();
    Bundle searchResult = ourClient.search().forResource(Patient.class).returnBundle(Bundle.class).cacheControl(new CacheControlDirective().setNoCache(true)).execute();
    assertEquals(1, searchResult.getEntry().size());
    Patient pt2 = (Patient) searchResult.getEntry().get(0).getResource();
    assertEquals("Family B", pt2.getName().get(0).getFamily());
}
Also used : IntegerType(org.hl7.fhir.r4.model.IntegerType) CacheControlDirective(ca.uhn.fhir.rest.api.CacheControlDirective) Bundle(org.hl7.fhir.r4.model.Bundle) CodeType(org.hl7.fhir.r4.model.CodeType) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 93 with CodeType

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

the class ObservationResourceProvider method findObservation.

@Search()
public List<Observation> findObservation(@RequiredParam(name = Observation.SP_SUBJECT) IdType theSubjectId, @OptionalParam(name = Observation.SP_CATEGORY) CodeType categoryCode, @OptionalParam(name = Observation.SP_CODE) CodeType code, @OptionalParam(name = Observation.SP_DATE) DateRangeParam dates, @OptionalParam(name = Observation.SP_ENCOUNTER) IdType contextId) {
    if (theSubjectId != null && !theSubjectId.isEmpty()) {
        Optional<IPatient> patient = modelService.load(theSubjectId.getIdPart(), IPatient.class);
        if (patient.isPresent()) {
            if (patient.get().isPatient()) {
                List<Observation> ret = new ArrayList<Observation>();
                // laboratory
                if (categoryCode == null || ObservationCategory.LABORATORY.name().equalsIgnoreCase(CodeTypeUtil.getCode(categoryCode).orElse(""))) {
                    List<Observation> intermediateRet = new ArrayList<>();
                    IQuery<ILabResult> resultQuery = modelService.getQuery(ILabResult.class);
                    resultQuery.and(ModelPackage.Literals.ILAB_RESULT__PATIENT, COMPARATOR.EQUALS, patient.get());
                    List<ILabResult> result = resultQuery.execute();
                    result.parallelStream().forEach(r -> getLabTransformer().getFhirObject(r).ifPresent(t -> intermediateRet.add(t)));
                    ret = sortLaboratory(intermediateRet);
                }
                // all other observations
                List<IObservation> findings = findingsService.getPatientsFindings(theSubjectId.getIdPart(), IObservation.class);
                if (findings != null && !findings.isEmpty()) {
                    for (IObservation iFinding : findings) {
                        if (categoryCode != null && !isObservationCategory(iFinding, categoryCode)) {
                            continue;
                        }
                        Optional<Observation> fhirObservation = getTransformer().getFhirObject(iFinding);
                        if (fhirObservation.isPresent()) {
                            ret.add(fhirObservation.get());
                        }
                    }
                }
                if (dates != null) {
                    ret = filterDates(ret, dates);
                }
                if (code != null) {
                    ret = filterCode(ret, code);
                }
                if (contextId != null) {
                    ret = filterContext(ret, contextId);
                }
                return ret;
            }
        }
    }
    return Collections.emptyList();
}
Also used : IdParam(ca.uhn.fhir.rest.annotation.IdParam) IFindingsService(ch.elexis.core.findings.IFindingsService) ModelPackage(ch.elexis.core.model.ModelPackage) IFhirTransformerRegistry(ch.elexis.core.findings.util.fhir.IFhirTransformerRegistry) ILabResult(ch.elexis.core.model.ILabResult) IFhirTransformer(ch.elexis.core.findings.util.fhir.IFhirTransformer) COMPARATOR(ch.elexis.core.services.IQuery.COMPARATOR) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) ArrayList(java.util.ArrayList) RequiredParam(ca.uhn.fhir.rest.annotation.RequiredParam) CodeTypeUtil(ch.elexis.core.findings.util.CodeTypeUtil) IModelService(ch.elexis.core.services.IModelService) Component(org.osgi.service.component.annotations.Component) DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Search(ca.uhn.fhir.rest.annotation.Search) ObservationCategory(ch.elexis.core.findings.IObservation.ObservationCategory) Observation(org.hl7.fhir.r4.model.Observation) Read(ca.uhn.fhir.rest.annotation.Read) IPatient(ch.elexis.core.model.IPatient) DateRangeParamUtil(ch.elexis.core.findings.util.DateRangeParamUtil) Create(ca.uhn.fhir.rest.annotation.Create) Collectors(java.util.stream.Collectors) InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) IdType(org.hl7.fhir.r4.model.IdType) CodingSystem(ch.elexis.core.findings.codes.CodingSystem) IObservation(ch.elexis.core.findings.IObservation) IQuery(ch.elexis.core.services.IQuery) List(java.util.List) ResourceParam(ca.uhn.fhir.rest.annotation.ResourceParam) Coding(org.hl7.fhir.r4.model.Coding) Optional(java.util.Optional) FHIRException(org.hl7.fhir.exceptions.FHIRException) CodeType(org.hl7.fhir.r4.model.CodeType) OptionalParam(ca.uhn.fhir.rest.annotation.OptionalParam) Comparator(java.util.Comparator) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) Observation(org.hl7.fhir.r4.model.Observation) IObservation(ch.elexis.core.findings.IObservation) ArrayList(java.util.ArrayList) ILabResult(ch.elexis.core.model.ILabResult) IPatient(ch.elexis.core.model.IPatient) IObservation(ch.elexis.core.findings.IObservation) Search(ca.uhn.fhir.rest.annotation.Search)

Example 94 with CodeType

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

the class ConditionResourceProvider method findCondition.

@Search()
public List<Condition> findCondition(@RequiredParam(name = Condition.SP_SUBJECT) IdType thePatientId, @OptionalParam(name = Condition.SP_CATEGORY) CodeType categoryCode) {
    if (thePatientId != null && !thePatientId.isEmpty()) {
        Optional<IPatient> patient = modelService.load(thePatientId.getIdPart(), IPatient.class);
        if (patient.isPresent()) {
            if (patient.get().isPatient()) {
                // migrate diagnose condition first
                migratorService.migratePatientsFindings(thePatientId.getIdPart(), ICondition.class, null);
                List<ICondition> findings = findingsService.getPatientsFindings(thePatientId.getIdPart(), ICondition.class);
                if (findings != null && !findings.isEmpty()) {
                    List<Condition> ret = new ArrayList<Condition>();
                    for (ICondition iFinding : findings) {
                        if (categoryCode != null && !isConditionCategory(iFinding, categoryCode)) {
                            continue;
                        }
                        Optional<Condition> fhirEncounter = getTransformer().getFhirObject(iFinding);
                        fhirEncounter.ifPresent(fe -> ret.add(fe));
                    }
                    return ret;
                }
            }
        }
    }
    return Collections.emptyList();
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) ICondition(ch.elexis.core.findings.ICondition) ArrayList(java.util.ArrayList) IPatient(ch.elexis.core.model.IPatient) ICondition(ch.elexis.core.findings.ICondition) Search(ca.uhn.fhir.rest.annotation.Search)

Example 95 with CodeType

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

the class CapabilityStatementSTU3 method populateCS.

public static CapabilityStatement populateCS(String server) {
    SimpleDateFormat sdfLess = new SimpleDateFormat("MM/dd/yyyy HH:mm");
    CapabilityStatement cs = new CapabilityStatement();
    cs.setPublisher("Centers for Medicare &amp; Medicaid Services");
    cs.setKind(CapabilityStatement.CapabilityStatementKind.INSTANCE);
    cs.setStatus(Enumerations.PublicationStatus.ACTIVE);
    String dt = sdfLess.format(new Date());
    try {
        cs.setDate(sdfLess.parse(dt));
    } catch (ParseException e) {
        cs.setDate(new Date());
    }
    cs.setAcceptUnknown(CapabilityStatement.UnknownContentCode.EXTENSIONS);
    cs.setFhirVersion(FhirVersionEnum.DSTU3.getFhirVersionString());
    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("V1");
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    try {
        Date releaseDate = sdf.parse("08/27/2020 00:00:00");
        cssc.setReleaseDate(releaseDate);
    } catch (Exception ex) {
        cssc.setReleaseDate(new Date());
    }
    cs.setSoftware(cssc);
    CapabilityStatement.CapabilityStatementImplementationComponent implementation = new CapabilityStatement.CapabilityStatementImplementationComponent();
    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.CapabilityStatementRestOperationComponent> 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) ParseException(java.text.ParseException) Coding(org.hl7.fhir.dstu3.model.Coding) CapabilityStatement(org.hl7.fhir.dstu3.model.CapabilityStatement) CodeType(org.hl7.fhir.dstu3.model.CodeType) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

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