Search in sources :

Example 26 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project ab2d by CMSgov.

the class AggregatorJobTest method createEob.

ExplanationOfBenefit createEob(int patientId) throws ParseException {
    final SimpleDateFormat SDF = new SimpleDateFormat("MM/dd/yyyy");
    ExplanationOfBenefit eob = (ExplanationOfBenefit) EobTestDataUtil.createEOB();
    eob.getBillablePeriod().setStart(SDF.parse("02/13/1970"));
    eob.getBillablePeriod().setEnd(new Date());
    eob.getMeta().setLastUpdated(new Date());
    eob.setPatient(new org.hl7.fhir.dstu3.model.Reference().setReference("Patient/" + patientId));
    return eob;
}
Also used : ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) FilterOutByDate(gov.cms.ab2d.filter.FilterOutByDate)

Example 27 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project integration-adaptor-111 by nhsconnect.

the class CompositionMapper method mapComposition.

public Composition mapComposition(POCDMT000002UK01ClinicalDocument1 clinicalDocument, Encounter encounter, List<CarePlan> carePlans, List<QuestionnaireResponse> questionnaireResponseList, ReferralRequest referralRequest, List<PractitionerRole> practitionerRoles) {
    Composition composition = new Composition();
    composition.setIdElement(resourceUtil.newRandomUuid());
    Identifier docIdentifier = new Identifier();
    docIdentifier.setUse(USUAL);
    docIdentifier.setValue(clinicalDocument.getSetId().getRoot());
    composition.setTitle(COMPOSITION_TITLE).setType(createCodeableConcept()).setStatus(FINAL).setEncounter(resourceUtil.createReference(encounter)).setSubject(encounter.getSubject()).setDateElement(DateUtil.parse(clinicalDocument.getEffectiveTime().getValue())).setIdentifier(docIdentifier);
    if (clinicalDocument.getConfidentialityCode().isSetCode()) {
        composition.setConfidentiality(Composition.DocumentConfidentiality.valueOf(clinicalDocument.getConfidentialityCode().getCode()));
    }
    if (isNotEmpty(clinicalDocument.getRelatedDocumentArray()) && clinicalDocument.getRelatedDocumentArray(0).getParentDocument().getIdArray(0).isSetRoot()) {
        Identifier relatedDocIdentifier = new Identifier();
        relatedDocIdentifier.setUse(USUAL);
        relatedDocIdentifier.setValue(clinicalDocument.getRelatedDocumentArray(0).getParentDocument().getIdArray(0).getRoot());
        composition.addRelatesTo().setCode(Composition.DocumentRelationshipType.REPLACES).setTarget(relatedDocIdentifier);
    }
    practitionerRoles.stream().forEach(it -> composition.addAuthor(it.getPractitioner()));
    if (clinicalDocument.getComponent().isSetStructuredBody()) {
        for (POCDMT000002UK01Component3 component3 : clinicalDocument.getComponent().getStructuredBody().getComponentArray()) {
            SectionComponent sectionComponent = new SectionComponent();
            addSectionChildren(sectionComponent, component3.getSection());
            composition.addSection(sectionComponent);
        }
    }
    for (CarePlan carePlan : carePlans) {
        composition.addSection(buildSectionComponentFromResource(carePlan));
    }
    if (!referralRequest.isEmpty()) {
        composition.addSection(buildSectionComponentFromResource(referralRequest));
    }
    if (questionnaireResponseList != null) {
        addPathwaysToSection(composition, questionnaireResponseList);
    }
    return composition;
}
Also used : Composition(org.hl7.fhir.dstu3.model.Composition) CarePlan(org.hl7.fhir.dstu3.model.CarePlan) Identifier(org.hl7.fhir.dstu3.model.Identifier) POCDMT000002UK01Component3(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Component3) SectionComponent(org.hl7.fhir.dstu3.model.Composition.SectionComponent)

Example 28 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project integration-adaptor-111 by nhsconnect.

the class ObservationMapper method createObservation.

private Observation createObservation(Encounter encounter, List<String> sectionText) {
    Observation observation = new Observation();
    observation.setIdElement(resourceUtil.newRandomUuid());
    observation.setStatus(FINAL);
    Coding coding = new Coding().setCode(PRESENTING_COMPLAINT_CODE).setDisplay(PRESENTING_COMPLAINT_DISPLAY).setSystem(SNOMED_SYSTEM);
    observation.setCode(new CodeableConcept(coding));
    observation.setValue(new StringType(join(sectionText, '\n')));
    observation.setContext(resourceUtil.createReference(encounter));
    observation.setSubject(encounter.getSubject());
    return observation;
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) StringType(org.hl7.fhir.dstu3.model.StringType) Observation(org.hl7.fhir.dstu3.model.Observation) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 29 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpansionCache method loadCache.

private void loadCache() throws FHIRFormatError, IOException {
    File[] files = new File(cacheFolder).listFiles();
    for (File f : files) {
        if (f.getName().endsWith(".xml")) {
            final FileInputStream is = new FileInputStream(f);
            try {
                Resource r = context.newXmlParser().setOutputStyle(OutputStyle.PRETTY).parse(is);
                if (r instanceof OperationOutcome) {
                    OperationOutcome oo = (OperationOutcome) r;
                    expansions.put(ToolingExtensions.getExtension(oo, VS_ID_EXT).getValue().toString(), new ValueSetExpansionOutcome(new XhtmlComposer(true, false).composePlainText(oo.getText().getDiv())));
                } else {
                    ValueSet vs = (ValueSet) r;
                    expansions.put(vs.getUrl(), new ValueSetExpansionOutcome(vs, null));
                }
            } finally {
                IOUtils.closeQuietly(is);
            }
        }
    }
}
Also used : OperationOutcome(org.hl7.fhir.dstu2016may.model.OperationOutcome) Resource(org.hl7.fhir.dstu2016may.model.Resource) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) ValueSetExpansionOutcome(org.hl7.fhir.dstu2016may.terminologies.ValueSetExpander.ValueSetExpansionOutcome) File(java.io.File) ValueSet(org.hl7.fhir.dstu2016may.model.ValueSet) FileInputStream(java.io.FileInputStream)

Example 30 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project org.hl7.fhir.core by hapifhir.

the class JavaResourceGenerator method writeSearchParameterField.

// private void generateImpl(String namenn, ResourceDefn resourceDefn, String jn, ElementDefinition root, String version, Date genDate) throws Exception {
// // TODO - restore this
// //    write("  public "+namenn+" get"+namenn+"() {\r\n");
// //    write("    return new "+jn+namenn+"Impl(this);\r\n");
// //    write("  }\r\n");
// //
// //    // now, generate the implementation
// //    JavaPatternImplGenerator jrg = new JavaPatternImplGenerator(new FileOutputStream(javaPatternDir+jn+namenn+"Impl.java"), definitions, adornments, enumInfo);
// //    jrg.generate(resourceDefn.getRoot(), jn, JavaGenClass.Resource, null, genDate, version, false, null, null, namenn, root);
// //    jrg.close();
// //
// }
private void writeSearchParameterField(String name, JavaGenClass clss, boolean isAbstract, SearchParameter sp, String code, String[] theCompositeOf, List<SearchParameter> searchParams, String rn) throws IOException {
    String constName = cleanSpName(code).toUpperCase();
    /*
     * SearchParamDefinition (SP_[name])
     */
    write(" /**\r\n");
    write("   * Search parameter: <b>" + code + "</b>\r\n");
    write("   * <p>\r\n");
    write("   * Description: <b>" + sp.getDescription() + "</b><br>\r\n");
    write("   * Type: <b>" + sp.getType().toCode() + "</b><br>\r\n");
    write("   * Path: <b>" + sp.getExpression() + "</b><br>\r\n");
    write("   * </p>\r\n");
    write("   */\r\n");
    write("  @SearchParamDefinition(name=\"" + code + "\", path=\"" + defaultString(sp.getExpression()) + "\", description=\"" + Utilities.escapeJava(sp.getDescription()) + "\", type=\"" + sp.getType().toCode() + "\"");
    if (theCompositeOf != null && theCompositeOf.length > 0) {
        write(", compositeOf={");
        for (int i = 0; i < theCompositeOf.length; i++) {
            if (i > 0) {
                write(", ");
            }
            write("\"" + theCompositeOf[i] + "\"");
        }
        write("}");
    }
    Set<String> providesMembershipIn = new TreeSet<String>();
    for (CompartmentDefinition next : this.definitions.getCompartments().getList()) {
        for (CompartmentDefinitionResourceComponent nextEntry : next.getResource()) {
            if (nextEntry.getCode().equals(upFirst(name))) {
                for (StringType nextPart : nextEntry.getParam()) {
                    if (nextPart.toString().equals(code)) {
                        providesMembershipIn.add(next.getName());
                    }
                }
            }
        }
    }
    if (providesMembershipIn.size() > 0) {
        write(", providesMembershipIn={ ");
        boolean first = true;
        for (String next : providesMembershipIn) {
            if (first) {
                first = false;
            } else {
                write(", ");
            }
            write("@ca.uhn.fhir.model.api.annotation.Compartment(name=\"" + upFirst(next) + "\")");
        }
        write(" }");
    }
    Set<String> targets = new TreeSet<>();
    for (CodeType c : sp.getTarget()) {
        targets.add(c.asStringValue());
    }
    if (targets != null && !targets.isEmpty() && !targets.contains("Any")) {
        write(", target={");
        boolean first = true;
        for (String nextTarget : targets) {
            if (first) {
                first = false;
            } else {
                write(", ");
            }
            write("List".equals(nextTarget) ? "ListResource" : nextTarget);
            write(".class");
        }
        write(" }");
    }
    write(" )\r\n");
    write("  public static final String SP_" + constName + " = \"" + code + "\";\r\n");
    String genericTypes = "";
    if (theCompositeOf != null && theCompositeOf.length > 0) {
        SearchParameter typeDef0 = findSearchParam(searchParams, theCompositeOf[0]);
        SearchParameter typeDef1 = findSearchParam(searchParams, theCompositeOf[1]);
        genericTypes = "<ca.uhn.fhir.rest.gclient." + upFirst(typeDef0.getType().toCode()) + "ClientParam" + ", ca.uhn.fhir.rest.gclient." + upFirst(typeDef1.getType().toCode()) + "ClientParam>";
    }
    /*
     * Client parameter ([name])
     */
    write(" /**\r\n");
    write("   * <b>Fluent Client</b> search parameter constant for <b>" + code + "</b>\r\n");
    write("   * <p>\r\n");
    write("   * Description: <b>" + sp.getDescription() + "</b><br>\r\n");
    write("   * Type: <b>" + sp.getType().toCode() + "</b><br>\r\n");
    write("   * Path: <b>" + sp.getExpression() + "</b><br>\r\n");
    write("   * </p>\r\n");
    write("   */\r\n");
    write("  public static final ca.uhn.fhir.rest.gclient." + upFirst(sp.getType().toCode()) + "ClientParam" + genericTypes + " " + constName + " = new ca.uhn.fhir.rest.gclient." + upFirst(sp.getType().toCode()) + "ClientParam" + genericTypes + "(SP_" + constName + ");\r\n\r\n");
    if (sp.getType() == SearchParamType.REFERENCE && clss == JavaGenClass.Resource && !isAbstract) {
        String incName = upFirst(name) + ":" + code;
        write("/**\r\n");
        write("   * Constant for fluent queries to be used to add include statements. Specifies\r\n");
        write("   * the path value of \"<b>" + incName + "</b>\".\r\n");
        write("   */\r\n");
        write("  public static final ca.uhn.fhir.model.api.Include INCLUDE_" + cleanSpName(code).toUpperCase() + " = new ca.uhn.fhir.model.api.Include(\"" + incName + "\").toLocked();\r\n\r\n");
    }
}
Also used : CompartmentDefinitionResourceComponent(org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent) StringType(org.hl7.fhir.r5.model.StringType) TreeSet(java.util.TreeSet) CompartmentDefinition(org.hl7.fhir.r5.model.CompartmentDefinition) CodeType(org.hl7.fhir.r5.model.CodeType) SearchParameter(org.hl7.fhir.r5.model.SearchParameter)

Aggregations

Test (org.junit.jupiter.api.Test)229 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)85 HashMap (java.util.HashMap)83 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)59 List (java.util.List)53 Bundle (org.hl7.fhir.dstu3.model.Bundle)50 Nonnull (javax.annotation.Nonnull)48 Patient (org.hl7.fhir.dstu3.model.Patient)46 Organization (org.hl7.fhir.dstu3.model.Organization)45 ArrayList (java.util.ArrayList)44 Bundle (org.hl7.fhir.r4.model.Bundle)41 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)39 UUID (java.util.UUID)38 Collectors (java.util.stream.Collectors)38 Coding (org.hl7.fhir.r4.model.Coding)34 FhirContext (ca.uhn.fhir.context.FhirContext)33 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)32 IParser (ca.uhn.fhir.parser.IParser)31 IOException (java.io.IOException)29 IdType (org.hl7.fhir.dstu3.model.IdType)28