Search in sources :

Example 1 with ResourceReferenceDt

use of ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt in project cqf-ruler by DBCG.

the class CompositionBuilder method initializeDstu2.

@Override
protected void initializeDstu2(T theResource) {
    super.initializeDstu2(theResource);
    ca.uhn.fhir.model.dstu2.resource.Composition composition = (ca.uhn.fhir.model.dstu2.resource.Composition) theResource;
    List<ResourceReferenceDt> author = new ArrayList<>();
    author.add(new ResourceReferenceDt(myAuthor));
    composition.setDate(new DateTimeDt(myDate)).setIdentifier(new IdentifierDt(getIdentifier().getKey(), getIdentifier().getValue())).setStatus(CompositionStatusEnum.forCode(myStatus)).setSubject(new ResourceReferenceDt(mySubject)).setTitle(myTitle).setType(new CodeableConceptDt().addCoding(new CodingDt().setSystem(getTypeSetting().getSystem()).setCode(getTypeSetting().getCode()).setDisplay(getTypeSetting().getDisplay()))).setAuthor(author).setCustodian(new ResourceReferenceDt(myCustodian));
}
Also used : IdentifierDt(ca.uhn.fhir.model.dstu2.composite.IdentifierDt) ResourceReferenceDt(ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt) CodeableConceptDt(ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt) ArrayList(java.util.ArrayList) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) CodingDt(ca.uhn.fhir.model.dstu2.composite.CodingDt)

Example 2 with ResourceReferenceDt

use of ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt in project cqf-ruler by DBCG.

the class DetectedIssueBuilder method initializeDstu2.

@Override
protected void initializeDstu2(T theResource) {
    super.initializeDstu2(theResource);
    ca.uhn.fhir.model.dstu2.resource.DetectedIssue detectedIssue = (ca.uhn.fhir.model.dstu2.resource.DetectedIssue) theResource;
    detectedIssue.setIdentifier(new IdentifierDt(getIdentifier().getKey(), getIdentifier().getValue())).setPatient(new ResourceReferenceDt(myPatient));
    getEvidenceDetails().forEach(detectedIssue::setReference);
}
Also used : IdentifierDt(ca.uhn.fhir.model.dstu2.composite.IdentifierDt) ResourceReferenceDt(ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt)

Example 3 with ResourceReferenceDt

use of ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt in project synthea by synthetichealth.

the class FhirDstu2 method procedure.

/**
 * Map the given Procedure into a FHIR Procedure resource, and add it to the given Bundle.
 *
 * @param rand
 *          Source of randomness to use when generating ids etc
 * @param personEntry
 *          The Person entry
 * @param bundle
 *          Bundle to add to
 * @param encounterEntry
 *          The current Encounter entry
 * @param procedure
 *          The Procedure
 * @return The added Entry
 */
private static Entry procedure(RandomNumberGenerator rand, Entry personEntry, Bundle bundle, Entry encounterEntry, Procedure procedure) {
    ca.uhn.fhir.model.dstu2.resource.Procedure procedureResource = new ca.uhn.fhir.model.dstu2.resource.Procedure();
    procedureResource.setStatus(ProcedureStatusEnum.COMPLETED);
    procedureResource.setSubject(new ResourceReferenceDt(personEntry.getFullUrl()));
    procedureResource.setEncounter(new ResourceReferenceDt(encounterEntry.getFullUrl()));
    Code code = procedure.codes.get(0);
    procedureResource.setCode(mapCodeToCodeableConcept(code, SNOMED_URI));
    if (procedure.stop != 0L) {
        Date startDate = new Date(procedure.start);
        Date endDate = new Date(procedure.stop);
        procedureResource.setPerformed(new PeriodDt().setStart(new DateTimeDt(startDate)).setEnd(new DateTimeDt(endDate)));
    } else {
        procedureResource.setPerformed(convertFhirDateTime(procedure.start, true));
    }
    if (!procedure.reasons.isEmpty()) {
        // Only one element in list
        Code reason = procedure.reasons.get(0);
        for (Entry entry : bundle.getEntry()) {
            if (entry.getResource().getResourceName().equals("Condition")) {
                Condition condition = (Condition) entry.getResource();
                // Only one element in list
                CodingDt coding = condition.getCode().getCoding().get(0);
                if (reason.code.equals(coding.getCode())) {
                    procedureResource.setReason(new ResourceReferenceDt(entry.getFullUrl()));
                }
            }
        }
    }
    Entry procedureEntry = newEntry(rand, bundle, procedureResource);
    procedure.fullUrl = procedureEntry.getFullUrl();
    return procedureEntry;
}
Also used : Condition(ca.uhn.fhir.model.dstu2.resource.Condition) ResourceReferenceDt(ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt) PeriodDt(ca.uhn.fhir.model.dstu2.composite.PeriodDt) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Date(java.util.Date) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) CodingDt(ca.uhn.fhir.model.dstu2.composite.CodingDt) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure)

Example 4 with ResourceReferenceDt

use of ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt in project synthea by synthetichealth.

the class FhirDstu2 method condition.

/**
 * Map the Condition into a FHIR Condition resource, and add it to the given Bundle.
 *
 * @param rand
 *          Source of randomness to use when generating ids etc
 * @param personEntry
 *          The Entry for the Person
 * @param bundle
 *          The Bundle to add to
 * @param encounterEntry
 *          The current Encounter entry
 * @param condition
 *          The Condition
 * @return The added Entry
 */
private static Entry condition(RandomNumberGenerator rand, Entry personEntry, Bundle bundle, Entry encounterEntry, HealthRecord.Entry condition) {
    Condition conditionResource = new Condition();
    conditionResource.setPatient(new ResourceReferenceDt(personEntry.getFullUrl()));
    conditionResource.setEncounter(new ResourceReferenceDt(encounterEntry.getFullUrl()));
    Code code = condition.codes.get(0);
    conditionResource.setCode(mapCodeToCodeableConcept(code, SNOMED_URI));
    conditionResource.setCategory(ConditionCategoryCodesEnum.DIAGNOSIS);
    conditionResource.setVerificationStatus(ConditionVerificationStatusEnum.CONFIRMED);
    conditionResource.setClinicalStatus(ConditionClinicalStatusCodesEnum.ACTIVE);
    conditionResource.setOnset(convertFhirDateTime(condition.start, true));
    conditionResource.setDateRecorded(new DateDt(new Date(condition.start)));
    if (condition.stop != 0) {
        conditionResource.setAbatement(convertFhirDateTime(condition.stop, true));
        conditionResource.setClinicalStatus(ConditionClinicalStatusCodesEnum.RESOLVED);
    }
    Entry conditionEntry = newEntry(rand, bundle, conditionResource);
    condition.fullUrl = conditionEntry.getFullUrl();
    return conditionEntry;
}
Also used : Condition(ca.uhn.fhir.model.dstu2.resource.Condition) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) ResourceReferenceDt(ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt) DateDt(ca.uhn.fhir.model.primitive.DateDt) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Date(java.util.Date)

Example 5 with ResourceReferenceDt

use of ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt in project synthea by synthetichealth.

the class FhirDstu2 method media.

/**
 * Map the given Media element to a FHIR Media resource, and add it to the given Bundle.
 *
 * @param rand           Source of randomness to use when generating ids etc
 * @param personEntry    The Entry for the Person
 * @param bundle         Bundle to add the Media to
 * @param encounterEntry Current Encounter entry
 * @param obs   The Observation to map to FHIR and add to the bundle
 * @return The added Entry
 */
private static Entry media(RandomNumberGenerator rand, Entry personEntry, Bundle bundle, Entry encounterEntry, Observation obs) {
    ca.uhn.fhir.model.dstu2.resource.Media mediaResource = new ca.uhn.fhir.model.dstu2.resource.Media();
    // Hard code as a photo
    mediaResource.setType(DigitalMediaTypeEnum.PHOTO);
    mediaResource.setSubject(new ResourceReferenceDt(personEntry.getFullUrl()));
    Attachment content = (Attachment) obs.value;
    ca.uhn.fhir.model.dstu2.composite.AttachmentDt contentResource = new ca.uhn.fhir.model.dstu2.composite.AttachmentDt();
    contentResource.setContentType(content.contentType);
    contentResource.setLanguage(content.language);
    if (content.data != null) {
        ca.uhn.fhir.model.primitive.Base64BinaryDt data = new ca.uhn.fhir.model.primitive.Base64BinaryDt();
        data.setValueAsString(content.data);
        contentResource.setData(data);
    }
    contentResource.setUrl(content.url);
    contentResource.setSize(content.size);
    contentResource.setTitle(content.title);
    if (content.hash != null) {
        ca.uhn.fhir.model.primitive.Base64BinaryDt hash = new ca.uhn.fhir.model.primitive.Base64BinaryDt();
        hash.setValueAsString(content.hash);
        contentResource.setHash(hash);
    }
    mediaResource.setWidth(content.width);
    mediaResource.setHeight(content.height);
    mediaResource.setContent(contentResource);
    return newEntry(rand, bundle, mediaResource);
}
Also used : ResourceReferenceDt(ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt) Attachment(org.mitre.synthea.engine.Components.Attachment)

Aggregations

ResourceReferenceDt (ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt)20 Entry (ca.uhn.fhir.model.dstu2.resource.Bundle.Entry)11 Date (java.util.Date)10 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)10 DateTimeDt (ca.uhn.fhir.model.primitive.DateTimeDt)8 Condition (ca.uhn.fhir.model.dstu2.resource.Condition)7 ArrayList (java.util.ArrayList)6 CodeableConceptDt (ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt)5 CodingDt (ca.uhn.fhir.model.dstu2.composite.CodingDt)5 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)5 PeriodDt (ca.uhn.fhir.model.dstu2.composite.PeriodDt)3 SimpleQuantityDt (ca.uhn.fhir.model.dstu2.composite.SimpleQuantityDt)3 DiagnosticReport (ca.uhn.fhir.model.dstu2.resource.DiagnosticReport)3 MedicationAdministration (ca.uhn.fhir.model.dstu2.resource.MedicationAdministration)3 BooleanDt (ca.uhn.fhir.model.primitive.BooleanDt)3 FhirContext (ca.uhn.fhir.context.FhirContext)2 BaseContainedDt (ca.uhn.fhir.model.base.composite.BaseContainedDt)2 BaseResourceReferenceDt (ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt)2 IdentifierDt (ca.uhn.fhir.model.dstu2.composite.IdentifierDt)2 Bundle (ca.uhn.fhir.model.dstu2.resource.Bundle)2