Search in sources :

Example 11 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project hl7v2-fhir-converter by LinuxForHealth.

the class HL7MessageEngine method initBundle.

private Bundle initBundle() {
    Bundle bundle = new Bundle();
    bundle.setType(this.bundleType);
    bundle.setId(UUID.randomUUID().toString());
    Meta m = new Meta();
    m.setLastUpdated(LocalDateTime.now().toDate());
    bundle.setMeta(m);
    return bundle;
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) Bundle(org.hl7.fhir.r4.model.Bundle)

Example 12 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project BridgeServer2 by Sage-Bionetworks.

the class CRCController method createPatient.

Patient createPatient(Account account) {
    Patient patient = new Patient();
    patient.setActive(true);
    patient.setId(account.getId());
    Identifier identifier = new Identifier();
    identifier.setValue(account.getId());
    identifier.setSystem(USER_ID_VALUE_NS);
    patient.addIdentifier(identifier);
    Coding coding = new Coding();
    coding.setSystem("source");
    coding.setCode("sage");
    Meta meta = new Meta();
    meta.setTag(ImmutableList.of(coding));
    patient.setMeta(meta);
    HumanName name = new HumanName();
    if (isNotBlank(account.getFirstName())) {
        name.addGiven(account.getFirstName());
    }
    if (isNotBlank(account.getLastName())) {
        name.setFamily(account.getLastName());
    }
    patient.addName(name);
    Map<String, String> atts = account.getAttributes();
    if (isNotBlank(atts.get("gender"))) {
        if ("female".equalsIgnoreCase(atts.get("gender"))) {
            patient.setGender(AdministrativeGender.FEMALE);
        } else if ("male".equalsIgnoreCase(atts.get("gender"))) {
            patient.setGender(AdministrativeGender.MALE);
        } else {
            patient.setGender(AdministrativeGender.OTHER);
        }
    } else {
        patient.setGender(AdministrativeGender.UNKNOWN);
    }
    if (isNotBlank(atts.get("dob"))) {
        LocalDate localDate = LocalDate.parse(atts.get("dob"));
        patient.setBirthDate(localDate.toDate());
    }
    Address address = new Address();
    if (isNotBlank(atts.get("address1"))) {
        address.addLine(atts.get("address1"));
    }
    if (isNotBlank(atts.get("address2"))) {
        address.addLine(atts.get("address2"));
    }
    if (isNotBlank(atts.get("city"))) {
        address.setCity(atts.get("city"));
    }
    if (isNotBlank(atts.get("state"))) {
        address.setState(atts.get("state"));
    } else {
        address.setState("NY");
    }
    if (isNotBlank(atts.get("zip_code"))) {
        address.setPostalCode(atts.get("zip_code"));
    }
    patient.addAddress(address);
    if (isNotBlank(atts.get("home_phone"))) {
        ContactPoint contact = new ContactPoint();
        contact.setSystem(ContactPointSystem.PHONE);
        contact.setValue(atts.get("home_phone"));
        patient.addTelecom(contact);
    }
    if (account.getPhone() != null && TRUE.equals(account.getPhoneVerified())) {
        ContactPoint contact = new ContactPoint();
        contact.setSystem(ContactPointSystem.SMS);
        contact.setValue(account.getPhone().getNumber());
        patient.addTelecom(contact);
    }
    if (account.getEmail() != null && TRUE.equals(account.getEmailVerified())) {
        ContactPoint contact = new ContactPoint();
        contact.setSystem(ContactPointSystem.EMAIL);
        contact.setValue(account.getEmail());
        patient.addTelecom(contact);
    }
    Reference ref = new Reference("CUZUCK");
    ref.setDisplay("COVID Recovery Corps");
    ContactComponent contact = new ContactComponent();
    contact.setOrganization(ref);
    patient.addContact(contact);
    return patient;
}
Also used : Meta(org.hl7.fhir.dstu3.model.Meta) HumanName(org.hl7.fhir.dstu3.model.HumanName) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) Identifier(org.hl7.fhir.dstu3.model.Identifier) Address(org.hl7.fhir.dstu3.model.Address) Coding(org.hl7.fhir.dstu3.model.Coding) Reference(org.hl7.fhir.dstu3.model.Reference) ContactComponent(org.hl7.fhir.dstu3.model.Patient.ContactComponent) Patient(org.hl7.fhir.dstu3.model.Patient) LocalDate(org.joda.time.LocalDate)

Example 13 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project cqf-ruler by DBCG.

the class ProcessMessageProvider method processMessageBundle.

@Operation(name = "$process-message-bundle", idempotent = false)
public Bundle processMessageBundle(HttpServletRequest theServletRequest, RequestDetails theRequestDetails, @OperationParam(name = "content", min = 1, max = 1) @Description(formalDefinition = "The message to process (or, if using asynchronous messaging, it may be a response message to accept)") Bundle theMessageToProcess) {
    logger.info("Validating the Bundle");
    Bundle bundle = theMessageToProcess;
    Boolean errorExists = false;
    OperationOutcome outcome = validateBundle(errorExists, bundle);
    if (!errorExists) {
        IVersionSpecificBundleFactory bundleFactory = this.getFhirContext().newBundleFactory();
        bundle.setId(getUUID());
        bundleFactory.initializeWithBundleResource(bundle);
        Bundle dafBundle = (Bundle) bundleFactory.getResourceBundle();
        dafBundle.setTimestamp(new Date());
        this.getDaoRegistry().getResourceDao(Bundle.class).create(dafBundle);
        MessageHeader messageHeader = null;
        String patientId = null;
        String commId = null;
        List<MessageHeader> headers = BundleUtil.toListOfResourcesOfType(this.getFhirContext(), bundle, MessageHeader.class);
        for (MessageHeader mh : headers) {
            messageHeader = mh;
            messageHeader.setId(getUUID());
            Meta meta = messageHeader.getMeta();
            meta.setLastUpdated(new Date());
            messageHeader.setMeta(meta);
        }
        List<IBaseResource> resources = new ArrayList<>();
        List<Patient> patients = BundleUtil.toListOfResourcesOfType(this.getFhirContext(), bundle, Patient.class);
        for (Patient p : patients) {
            patientId = p.getId();
            p.setId(p.getIdElement().toVersionless());
            resources.add(p);
        }
        List<Bundle> bundles = BundleUtil.toListOfResourcesOfType(this.getFhirContext(), bundle, Bundle.class);
        for (Bundle b : bundles) {
            patientId = this.processBundle(b, theRequestDetails);
            b.setId(b.getIdElement().toVersionless());
            resources.add(b);
        }
        for (BundleEntryComponent e : bundle.getEntry()) {
            Resource r = e.getResource();
            if (r == null) {
                continue;
            }
            if (r.fhirType().equals("Bundle") || r.fhirType().equals("MessageHeader") || r.fhirType().equals("Patient")) {
                continue;
            }
            r.setId(r.getIdElement().toVersionless());
            resources.add(r);
        }
        if (patientId != null) {
            commId = constructAndSaveCommunication(patientId);
        }
        if (messageHeader == null) {
            messageHeader = constructMessageHeaderResource();
            BundleEntryComponent entryComp = new BundleEntryComponent();
            entryComp.setResource(messageHeader);
            dafBundle.addEntry(entryComp);
        }
        if (commId != null) {
            List<Reference> referenceList = new ArrayList<>();
            Reference commRef = new Reference();
            commRef.setReference("Communication/" + commId);
            referenceList.add(commRef);
            messageHeader.setFocus(referenceList);
        }
        IVersionSpecificBundleFactory newBundleFactory = this.getFhirContext().newBundleFactory();
        newBundleFactory.addResourcesToBundle(resources, BundleTypeEnum.TRANSACTION, theRequestDetails.getFhirServerBase(), null, null);
        Bundle transactionBundle = (Bundle) newBundleFactory.getResourceBundle();
        for (BundleEntryComponent entry : transactionBundle.getEntry()) {
            UriType uri = new UriType(theRequestDetails.getFhirServerBase() + "/" + entry.getResource().fhirType() + "/" + entry.getResource().getIdElement().getIdPart());
            Enumeration<HTTPVerb> method = new Enumeration<>(new HTTPVerbEnumFactory());
            method.setValue(HTTPVerb.PUT);
            entry.setRequest(new BundleEntryRequestComponent(method, uri));
        }
        @SuppressWarnings("unchecked") IFhirSystemDao<Bundle, Meta> fhirSystemDao = this.getDaoRegistry().getSystemDao();
        fhirSystemDao.transaction(theRequestDetails, transactionBundle);
        return dafBundle;
    } else {
        BundleEntryComponent entryComp = new BundleEntryComponent();
        entryComp.setResource(outcome);
        bundle.addEntry(entryComp);
        return bundle;
    }
}
Also used : HTTPVerb(org.hl7.fhir.r4.model.Bundle.HTTPVerb) Meta(org.hl7.fhir.r4.model.Meta) ArrayList(java.util.ArrayList) UriType(org.hl7.fhir.r4.model.UriType) BundleEntryRequestComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) Enumeration(org.hl7.fhir.r4.model.Enumeration) Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) IVersionSpecificBundleFactory(ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory) Patient(org.hl7.fhir.r4.model.Patient) HTTPVerbEnumFactory(org.hl7.fhir.r4.model.Bundle.HTTPVerbEnumFactory) Date(java.util.Date) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) MessageHeader(org.hl7.fhir.r4.model.MessageHeader) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Operation(ca.uhn.fhir.rest.annotation.Operation)

Example 14 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project cqf-ruler by DBCG.

the class ReportProvider method patientReport.

private Parameters.ParametersParameterComponent patientReport(Patient thePatient, Period thePeriod, String serverBase) {
    String patientId = thePatient.getIdElement().getIdPart();
    final Map<IIdType, IAnyResource> bundleEntries = new HashMap<>();
    bundleEntries.put(thePatient.getIdElement(), thePatient);
    ReferenceParam subjectParam = new ReferenceParam(patientId);
    search(MeasureReport.class, Searches.byParam("subject", subjectParam)).getAllResourcesTyped().forEach(measureReport -> {
        if (measureReport.getPeriod().getEnd().before(thePeriod.getStart()) || measureReport.getPeriod().getStart().after(thePeriod.getEnd())) {
            return;
        }
        bundleEntries.putIfAbsent(measureReport.getIdElement(), measureReport);
        getEvaluatedResources(measureReport).values().forEach(resource -> bundleEntries.putIfAbsent(resource.getIdElement(), resource));
    });
    Bundle patientReportBundle = new Bundle();
    patientReportBundle.setMeta(new Meta().addProfile(PATIENT_REPORT_PROFILE_URL));
    patientReportBundle.setType(Bundle.BundleType.COLLECTION);
    patientReportBundle.setTimestamp(new Date());
    patientReportBundle.setId(patientId + "-report");
    patientReportBundle.setIdentifier(new Identifier().setSystem("urn:ietf:rfc:3986").setValue("urn:uuid:" + UUID.randomUUID().toString()));
    bundleEntries.entrySet().forEach(resource -> patientReportBundle.addEntry(new Bundle.BundleEntryComponent().setResource((Resource) resource.getValue()).setFullUrl(Operations.getFullUrl(serverBase, resource.getValue().fhirType(), resource.getValue().getIdElement().getIdPart()))));
    Parameters.ParametersParameterComponent patientParameter = new Parameters.ParametersParameterComponent();
    patientParameter.setResource(patientReportBundle);
    patientParameter.setId(thePatient.getIdElement().getIdPart() + "-report");
    patientParameter.setName("return");
    return patientParameter;
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) Parameters(org.hl7.fhir.r4.model.Parameters) HashMap(java.util.HashMap) Bundle(org.hl7.fhir.r4.model.Bundle) IAnyResource(org.hl7.fhir.instance.model.api.IAnyResource) Resource(org.hl7.fhir.r4.model.Resource) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) Date(java.util.Date) Identifier(org.hl7.fhir.r4.model.Identifier) IAnyResource(org.hl7.fhir.instance.model.api.IAnyResource) IIdType(org.hl7.fhir.instance.model.api.IIdType)

Example 15 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project cqf-ruler by DBCG.

the class CareGapsProvider method initializeReport.

private void initializeReport(MeasureReport report) {
    if (Strings.isNullOrEmpty(report.getId())) {
        IIdType id = Ids.newId(MeasureReport.class, UUID.randomUUID().toString());
        report.setId(id);
    }
    Reference reporter = new Reference().setReference(crProperties.getMeasureReport().getReporter());
    // TODO: figure out what this extension is for
    // reporter.addExtension(new
    // Extension().setUrl(CARE_GAPS_MEASUREREPORT_REPORTER_EXTENSION));
    report.setReporter(reporter);
    if (report.hasMeta()) {
        report.getMeta().addProfile(CARE_GAPS_REPORT_PROFILE);
    } else {
        report.setMeta(new Meta().addProfile(CARE_GAPS_REPORT_PROFILE));
    }
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) Reference(org.hl7.fhir.r4.model.Reference) IIdType(org.hl7.fhir.instance.model.api.IIdType)

Aggregations

Meta (org.hl7.fhir.r4.model.Meta)35 Date (java.util.Date)33 Reference (org.hl7.fhir.r4.model.Reference)26 Meta (org.hl7.fhir.dstu3.model.Meta)25 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)20 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)18 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)17 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)17 ArrayList (java.util.ArrayList)16 Coding (org.hl7.fhir.r4.model.Coding)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)15 Test (org.junit.Test)14 NotImplementedException (org.apache.commons.lang3.NotImplementedException)13 Reference (org.hl7.fhir.dstu3.model.Reference)11 Identifier (org.hl7.fhir.r4.model.Identifier)10 Test (org.junit.jupiter.api.Test)10 Element (org.w3c.dom.Element)10 HashMap (java.util.HashMap)9 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)9 Bundle (org.hl7.fhir.r4.model.Bundle)9