org.hl7.fhir.dstu3.model.Meta Java Examples

The following examples show how to use org.hl7.fhir.dstu3.model.Meta. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FhirTransactionTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("JdkObsolete")
public void transactionTest() {
    Bundle bundle = new Bundle();
    bundle.addEntry(new Bundle.BundleEntryComponent().setResource(new Account().setId("1").setMeta(new Meta().setLastUpdated(new Date()))));
    bundle.addEntry(new Bundle.BundleEntryComponent().setResource(new Patient().setId("2").setMeta(new Meta().setLastUpdated(new Date()))));
    stubFhirRequest(post(urlEqualTo("/?_format=xml")).withRequestBody(containing(
        "<type value=\"transaction\"/><total value=\"2\"/><link><relation value=\"fhir-base\"/></link>" +
            "<link><relation value=\"self\"/></link>" +
            "<entry><resource><Account xmlns=\"http://hl7.org/fhir\"><name value=\"Joe\"/></Account></resource>" +
            "<request><method value=\"POST\"/></request></entry><entry><resource>" +
            "<Patient xmlns=\"http://hl7.org/fhir\"><name><family value=\"Jackson\"/></name></Patient></resource>" +
            "<request><method value=\"POST\"/></request></entry>")).willReturn(okXml(toXml(bundle))));

    template.requestBody("direct:start",
        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
            "<tns:Transaction xmlns:tns=\"http://hl7.org/fhir\">" +
            "<tns:Account><tns:name value=\"Joe\"/></tns:Account>" +
            "<tns:Patient><name><tns:family value=\"Jackson\"/></name></tns:Patient></tns:Transaction>");
}
 
Example #2
Source File: LoincToDEConvertor.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public Bundle process(String sourceFile) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
  this.definitions = sourceFile;
  log("Begin. Produce Loinc CDEs in "+dest+" from "+definitions);
  loadLoinc();
  log("LOINC loaded");

  now = DateTimeType.now();

  bundle = new Bundle();
  bundle.setType(BundleType.COLLECTION);
  bundle.setId("http://hl7.org/fhir/commondataelement/loinc");
  bundle.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));

  processLoincCodes();
  return bundle;
}
 
Example #3
Source File: LoincToDEConvertor.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public void process() throws FHIRFormatError, IOException, XmlPullParserException, SAXException, ParserConfigurationException {
	log("Begin. Produce Loinc CDEs in "+dest+" from "+definitions);
	loadLoinc();
	log("LOINC loaded");

	now = DateTimeType.now();

	bundle = new Bundle();
	bundle.setId("http://hl7.org/fhir/commondataelement/loinc");
   bundle.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));

	processLoincCodes();
	if (dest != null) {
		log("Saving...");
		saveBundle();
	}
	log("Done");

}
 
Example #4
Source File: CCDAConverter.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
protected String addReference(DomainResource r, String title, String id) throws Exception {
	if (r.getText() == null)
		r.setText(new Narrative());
	if (r.getText().getDiv() == null) {
		r.getText().setStatus(NarrativeStatus.GENERATED);
		new NarrativeGenerator("", "", context).generate(r);
	}
	r.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));
	r.setId(id);
	feed.getEntry().add(new BundleEntryComponent().setResource(r));
	return id;
}
 
Example #5
Source File: MetaTest.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Test
public void testMetaSecurity() {
  Meta meta = new Meta();
  Coding coding = meta.addSecurity().setSystem(TEST_SYSTEM).setCode(TEST_CODE);
  Assertions.assertTrue(meta.hasSecurity());
  Assertions.assertNotNull(meta.getSecurity());
  Assertions.assertNotNull(meta.getSecurity(TEST_SYSTEM, TEST_CODE));
  Assertions.assertEquals(1, meta.getSecurity().size());
  Assertions.assertEquals(meta.getSecurity().get(0), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
  Assertions.assertEquals(meta.getSecurityFirstRep(), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
  Assertions.assertEquals(coding, meta.getSecurity(TEST_SYSTEM, TEST_CODE));
}
 
Example #6
Source File: ValueSetUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static ValueSet makeShareable(ValueSet vs) {
  if (!vs.hasMeta())
    vs.setMeta(new Meta());
  for (UriType t : vs.getMeta().getProfile()) 
    if (t.getValue().equals("http://hl7.org/fhir/StructureDefinition/shareablevalueset"))
      return vs;
  vs.getMeta().getProfile().add(new UriType("http://hl7.org/fhir/StructureDefinition/shareablevalueset"));
  return vs;
}
 
Example #7
Source File: CodeSystemUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static CodeSystem makeShareable(CodeSystem cs) {
  if (!cs.hasMeta())
    cs.setMeta(new Meta());
  for (UriType t : cs.getMeta().getProfile()) 
    if (t.getValue().equals("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"))
      return cs;
  cs.getMeta().getProfile().add(new UriType("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"));
  return cs;
}
 
Example #8
Source File: FhirDstu3Processor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep(onlyIf = FhirFlags.Dstu3Enabled.class)
void enableReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        Dstu3PropertiesBuildItem propertiesBuildItem) {
    Set<String> classes = new HashSet<>();
    classes.add(DomainResource.class.getCanonicalName());
    classes.add(Resource.class.getCanonicalName());
    classes.add(org.hl7.fhir.dstu3.model.BaseResource.class.getCanonicalName());
    classes.add(Base.class.getCanonicalName());
    classes.addAll(getModelClasses(propertiesBuildItem.getProperties()));
    classes.addAll(getInnerClasses(Enumerations.class.getCanonicalName()));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, true, Meta.class.getCanonicalName()));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, true, MetadataResource.class.getCanonicalName()));
    reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, classes.toArray(new String[0])));
}
 
Example #9
Source File: LoincToDEConvertor.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void processLoincCodes() {
	Element row = XMLUtil.getFirstChild(xml.getDocumentElement());
	int i = 0;
	while (row != null) {
		i++;
		if (i % 1000 == 0)
			System.out.print(".");
			String code = col(row, "LOINC_NUM");
			String comp = col(row, "COMPONENT");
			DataElement de = new DataElement();
			de.setId("loinc-"+code);
	    de.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));
			bundle.getEntry().add(new BundleEntryComponent().setResource(de));
			Identifier id = new Identifier();
			id.setSystem("http://hl7.org/fhir/commondataelement/loinc");
			id.setValue(code);
			de.addIdentifier(id);
			de.setPublisher("Regenstrief + FHIR Project Team");
			if (!col(row, "STATUS").equals("ACTIVE"))
 				de.setStatus(PublicationStatus.DRAFT); // till we get good at this
			else
				de.setStatus(PublicationStatus.RETIRED);
			de.setDateElement(DateTimeType.now());
			de.setName(comp);
			ElementDefinition dee = de.addElement();

			// PROPERTY	ignore
			// TIME_ASPCT	
			// SYSTEM	
			// SCALE_TYP	
			// METHOD_TYP	
			// dee.getCategory().add(new CodeableConcept().setText(col(row, "CLASS")));
			// SOURCE	
			// DATE_LAST_CHANGED - should be in ?	
			// CHNG_TYPE	
			dee.setComment(col(row , "COMMENTS"));
			if (hasCol(row, "CONSUMER_NAME"))
				dee.addAlias(col(row, "CONSUMER_NAME"));	
			// MOLAR_MASS	
			// CLASSTYPE	
			// FORMULA	
			// SPECIES	
			// EXMPL_ANSWERS	
			// ACSSYM	
			// BASE_NAME - ? this is a relationship	
			// NAACCR_ID	
			// ---------- CODE_TABLE todo	
			// SURVEY_QUEST_TEXT	
			// SURVEY_QUEST_SRC	
			if (hasCol(row, "RELATEDNAMES2")) {
        String n = col(row, "RELATEDNAMES2");
        for (String s : n.split("\\;")) {
					if (!Utilities.noString(s))
						dee.addAlias(s);	
        }
			}
			dee.addAlias(col(row, "SHORTNAME"));	
			// ORDER_OBS	
			// CDISC Code	
			// HL7_FIELD_SUBFIELD_ID	
			//  ------------------ EXTERNAL_COPYRIGHT_NOTICE todo	
			dee.setDefinition(col(row, "LONG_COMMON_NAME"));	
			// HL7_V2_DATATYPE	
			String cc = makeType(col(row, "HL7_V3_DATATYPE"), code);
			if (cc != null)
			  dee.addType().setCode(cc);	
			// todo... CURATED_RANGE_AND_UNITS	
			// todo: DOCUMENT_SECTION	
			// STATUS_REASON	
			// STATUS_TEXT	
			// CHANGE_REASON_PUBLIC	
			// COMMON_TEST_RANK	
			// COMMON_ORDER_RANK	
			// COMMON_SI_TEST_RANK	
			// HL7_ATTACHMENT_STRUCTURE

			// units:
			// UNITSREQUIRED	
			// SUBMITTED_UNITS
			ToolingExtensions.setAllowableUnits(dee, makeUnits(col(row, "EXAMPLE_UNITS"), col(row, "EXAMPLE_UCUM_UNITS")));
			// EXAMPLE_SI_UCUM_UNITS	
		
		row = XMLUtil.getNextSibling(row);
	}
	System.out.println("done");
}
 
Example #10
Source File: ResourceUtilities.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public static Meta meta(Resource resource) {
  if (!resource.hasMeta())
    resource.setMeta(new Meta());
  return resource.getMeta();
}
 
Example #11
Source File: PractitionerRoleToFHIRPractitionerRoleTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public org.hl7.fhir.dstu3.model.PractitionerRole transform(final PractitionerRole roleEntity) {
    final org.hl7.fhir.dstu3.model.PractitionerRole practitionerRole = new org.hl7.fhir.dstu3.model.PractitionerRole();

    Meta meta = new Meta().addProfile(CareConnectProfile.PractitionerRole_1);

    if (roleEntity.getUpdated() != null) {
        meta.setLastUpdated(roleEntity.getUpdated());
    }
    else {
        if (roleEntity.getCreated() != null) {
            meta.setLastUpdated(roleEntity.getCreated());
        }
    }

    practitionerRole.setId(roleEntity.getId().toString());

    for(PractitionerRoleIdentifier identifier : roleEntity.getIdentifiers())
    {
        Identifier ident = practitionerRole.addIdentifier();
        ident = daoutils.getIdentifier(identifier, ident);
    }


    if (roleEntity.getOrganisation() != null) {
        practitionerRole.getOrganization()
                .setReference("Organization/"+roleEntity.getOrganisation().getId())
                .setDisplay(roleEntity.getOrganisation().getName());
    }
    if (roleEntity.getRole() != null) {
        CodeableConcept role = new CodeableConcept();
        role.addCoding()
                .setCode(roleEntity.getRole().getCode())
                .setDisplay(roleEntity.getRole().getDisplay())
                .setSystem(roleEntity.getRole().getSystem());
        practitionerRole.getCode().add(role);
    }
    if (roleEntity.getPractitioner() != null) {
        practitionerRole.getPractitioner()
                .setReference("Practitioner/"+roleEntity.getPractitioner().getId())
                .setDisplay(roleEntity.getPractitioner().getNames().get(0).getDisplayName());
    }
    for (PractitionerSpecialty specialty : roleEntity.getSpecialties()) {
        CodeableConcept concept = new CodeableConcept();
        concept.addCoding()
                .setCode(specialty.getSpecialty().getCode())
                .setDisplay(specialty.getSpecialty().getDisplay())
                .setSystem(specialty.getSpecialty().getSystem());
        practitionerRole.addSpecialty(concept);
    }



    return practitionerRole;

}
 
Example #12
Source File: EndpointEntityToFHIREndpointTransform.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public Endpoint transform(EndpointEntity endpointEntity) {
    final Endpoint endpoint = new Endpoint();



    Meta meta = new Meta();

    if (endpointEntity.getUpdated() != null) {
        meta.setLastUpdated(endpointEntity.getUpdated());
    }
    else {
        if (endpointEntity.getCreated() != null) {
            meta.setLastUpdated(endpointEntity.getCreated());
        }
    }
    endpoint.setMeta(meta);


    if (endpointEntity.getStatus() != null) {
        endpoint.setStatus(endpointEntity.getStatus());
    }


    for(EndpointIdentifier identifier: endpointEntity.getIdentifiers())
    {
        Identifier ident = endpoint.addIdentifier();
        ident = daoutils.getIdentifier(identifier, ident);
    }

    endpoint.setId(endpointEntity.getId().toString());

    log.trace("endpoint tfm3");
    if (endpointEntity.getName() != null) {
        endpoint.setName(endpointEntity.getName());
    }

    if (endpointEntity.getManagingOrganisation() != null) {
        endpoint.setManagingOrganization(new Reference("Organization/"+endpointEntity.getManagingOrganisation().getId()));
        endpoint.getManagingOrganization().setDisplay(endpointEntity.getManagingOrganisation().getName());
    }
    log.trace("endpoint tfm4");
    if (endpointEntity.getConnectionType()!=null) {
        endpoint.getConnectionType()
                .setCode(endpointEntity.getConnectionType().getCode())
                .setDisplay(endpointEntity.getConnectionType().getDisplay())
                .setSystem(endpointEntity.getConnectionType().getSystem());
    }

    log.trace("endpoint tfm5");
    if (endpointEntity.getAddress() != null) {
        endpoint.setAddress(endpointEntity.getAddress());
    }

    log.trace("endpoint tfm6");

    for(EndpointPayloadType endpointPayloadType : endpointEntity.getPayloadTypes()) {
        endpoint.addPayloadType()
                .addCoding()
                .setSystem(endpointPayloadType.getPayloadType().getSystem())
                .setCode(endpointPayloadType.getPayloadType().getCode())
                .setDisplay(endpointPayloadType.getPayloadType().getDisplay());
    }
    for(EndpointPayloadMime endpointPayloadMime : endpointEntity.getPayloadMimes()) {
        endpoint.addPayloadMimeType(endpointPayloadMime.getMimeType().getCode());
    }

    return endpoint;
}
 
Example #13
Source File: DiagnosticReportEntityToFHIRDiagnosticReportTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public DiagnosticReport transform(final DiagnosticReportEntity diagnosticReportEntity) {
    final DiagnosticReport diagnosticReport = new DiagnosticReport();

    Meta meta = new Meta();
            //.addProfile(CareConnectProfile.Condition_1);

    if (diagnosticReportEntity.getUpdated() != null) {
        meta.setLastUpdated(diagnosticReportEntity.getUpdated());
    }
    else {
        if (diagnosticReportEntity.getCreated() != null) {
            meta.setLastUpdated(diagnosticReportEntity.getCreated());
        }
    }
    diagnosticReport.setMeta(meta);

    diagnosticReport.setId(diagnosticReportEntity.getId().toString());



    if (diagnosticReportEntity.getStatus() != null) {
        diagnosticReport.setStatus(diagnosticReportEntity.getStatus());
    }

    if (diagnosticReportEntity.getPatient() != null) {
        diagnosticReport
                .setSubject(new Reference("Patient/"+diagnosticReportEntity.getPatient().getId())
                .setDisplay(diagnosticReportEntity.getPatient().getNames().get(0).getDisplayName()));
    }



    for (DiagnosticReportIdentifier identifier : diagnosticReportEntity.getIdentifiers()) {
        Identifier ident = diagnosticReport.addIdentifier();
        ident = daoutils.getIdentifier(identifier, ident);
    }

    for (DiagnosticReportResult reportResult : diagnosticReportEntity.getResults()) {
        diagnosticReport.addResult(new Reference("Observation/"+reportResult.getObservation().getId()));
    }

    return diagnosticReport;

}
 
Example #14
Source File: PractitionerEntityToFHIRPractitionerTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public Practitioner transform(final PractitionerEntity practitionerEntity) {
    final Practitioner practitioner = new Practitioner();

    Meta meta = new Meta().addProfile(CareConnectProfile.Practitioner_1);

    if (practitionerEntity.getUpdated() != null) {
        meta.setLastUpdated(practitionerEntity.getUpdated());
    }
    else {
        if (practitionerEntity.getCreated() != null) {
            meta.setLastUpdated(practitionerEntity.getCreated());
        }
    }
    practitioner.setMeta(meta);
    if (practitionerEntity.getActive() != null) {
        practitioner.setActive(practitionerEntity.getActive());
    }

    for(PractitionerIdentifier identifier :practitionerEntity.getIdentifiers())
    {
        Identifier ident = practitioner.addIdentifier();
        ident = daoutils.getIdentifier(identifier, ident);
    }

    practitioner.setId(practitionerEntity.getId().toString());

    if (practitionerEntity.getNames().size() > 0) {

        practitioner.addName()
                .setFamily(practitionerEntity.getNames().get(0).getFamilyName())
                .addGiven(practitionerEntity.getNames().get(0).getGivenName())
                .addPrefix(practitionerEntity.getNames().get(0).getPrefix());
    }
    for(int f=0;f<practitionerEntity.getTelecoms().size();f++)
    {
        practitioner.addTelecom()
                .setSystem(practitionerEntity.getTelecoms().get(f).getSystem())
                .setValue(practitionerEntity.getTelecoms().get(f).getValue())
                .setUse(practitionerEntity.getTelecoms().get(f).getTelecomUse());
    }


    for (PractitionerAddress practitionerAddress : practitionerEntity.getAddresses()){
        Address address = addressTransformer.transform(practitionerAddress);
        practitioner.addAddress(address);
    }

    if (practitionerEntity.getGender() !=null)
    {
        practitioner.setGender(daoutils.getGender(practitionerEntity.getGender()));
    }

    return practitioner;

}
 
Example #15
Source File: SlotEntityToFHIRSlotTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public Slot transform(final SlotEntity slotEntity) {

    final Slot slot = new Slot();

    Meta meta = new Meta(); //.addProfile(CareConnectProfile.Location_1);

    if (slotEntity.getUpdated() != null) {
        meta.setLastUpdated(slotEntity.getUpdated());
    }
    else {
        if (slotEntity.getCreated() != null) {
            meta.setLastUpdated(slotEntity.getCreated());
        }
    }
    slot.setMeta(meta);

    slot.setId(slotEntity.getId().toString());

    for(SlotIdentifier identifier : slotEntity.getIdentifiers())
    {
        Identifier ident = slot.addIdentifier();
        ident = daoutils.getIdentifier(identifier, ident);
    }

    if (slotEntity.getServiceCategory() != null) {
        slot.getServiceCategory()
                .addCoding()
                .setDisplay(slotEntity.getServiceCategory().getDisplay())
                .setSystem(slotEntity.getServiceCategory().getSystem())
                .setCode(slotEntity.getServiceCategory().getCode());
    }

    if (slotEntity.getAppointmentType() != null) {
        slot.getAppointmentType()
                .addCoding()
                .setDisplay(slotEntity.getAppointmentType().getDisplay())
                .setSystem(slotEntity.getAppointmentType().getSystem())
                .setCode(slotEntity.getAppointmentType().getCode());
    }

    if (slotEntity.getSchedule() != null) {
        slot.setSchedule(new Reference("Schedule/"+slotEntity.getSchedule().getId()));
    }

    if (slotEntity.getStatus() != null) {
        slot.setStatus(slotEntity.getStatus());
    }
    if (slotEntity.getStart() != null) {
        slot.setStart(slotEntity.getStart());
    }

    if (slotEntity.getEnd() != null) {
        slot.setEnd(slotEntity.getEnd());
    }

    return slot;

}
 
Example #16
Source File: HealthcareServiceEntityToFHIRHealthcareServiceTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
    public HealthcareService transform(final HealthcareServiceEntity serviceEntity) {
        final HealthcareService service = new HealthcareService();

        Meta meta = new Meta(); //.addProfile(CareConnectProfile.Location_1);

        if (serviceEntity.getUpdated() != null) {
            meta.setLastUpdated(serviceEntity.getUpdated());
        }
        else {
            if (serviceEntity.getCreated() != null) {
                meta.setLastUpdated(serviceEntity.getCreated());
            }
        }
        service.setMeta(meta);

        service.setId(serviceEntity.getId().toString());

        for(HealthcareServiceIdentifier identifier : serviceEntity.getIdentifiers())
        {
            Identifier ident = service.addIdentifier();
            ident = daoutils.getIdentifier(identifier, ident);
        }

        if (serviceEntity.getActive() != null) {
            service.setActive(serviceEntity.getActive());
        }
        if (serviceEntity.getName() != null) {
            service.setName(serviceEntity.getName());
        }

        if (serviceEntity.getComment() != null) {
            service.setComment(serviceEntity.getComment());
        }

        if (serviceEntity.getCategory() != null) {
            service.getCategory()
                    .addCoding()
                    .setDisplay(serviceEntity.getCategory().getDisplay())
                    .setSystem(serviceEntity.getCategory().getSystem())
                    .setCode(serviceEntity.getCategory().getCode());
        }

        System.out.println("Provided By: " + serviceEntity.getProvidedBy().getId());
        if (serviceEntity.getProvidedBy() != null) {
            service.setProvidedBy(new Reference("Organization/"+serviceEntity.getProvidedBy().getId()).setDisplay(serviceEntity.getProvidedBy().getName()));
        }
        for (HealthcareServiceSpecialty serviceSpecialty : serviceEntity.getSpecialties()) {
            service.addSpecialty()
                    .addCoding()
                        .setCode(serviceSpecialty.getSpecialty().getCode())
                        .setSystem(serviceSpecialty.getSpecialty().getSystem())
                        .setDisplay(serviceSpecialty.getSpecialty().getDisplay());
        }
        for (HealthcareServiceLocation serviceLocation : serviceEntity.getLocations()) {
            service.addLocation(new Reference("Location/"+serviceLocation.getLocation().getId()).setDisplay(serviceLocation.getLocation().getName()));
        }

        for (HealthcareServiceTelecom serviceTelecom : serviceEntity.getTelecoms()) {
            service.addTelecom()
                    .setSystem(serviceTelecom.getSystem())
                    .setValue(serviceTelecom.getValue())
                    .setUse(serviceTelecom.getTelecomUse());

        }
/*        for (HealthcareServiceType serviceType : serviceEntity.getTypes()) {
            service.addType()
                    .addCoding()
                    .setCode(serviceType.getType_().getCode())
                    .setSystem(serviceType.getType_().getSystem())
                    .setDisplay(serviceType.getType_().getDisplay());
        }*/


        return service;

    }
 
Example #17
Source File: ScheduleEntityToFHIRScheduleTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public Schedule transform(final ScheduleEntity scheduleEntity) {

        final Schedule schedule = new Schedule();

        Meta meta = new Meta(); //.addProfile(CareConnectProfile.Location_1);

        if (scheduleEntity.getUpdated() != null) {
            meta.setLastUpdated(scheduleEntity.getUpdated());
        }
        else {
            if (scheduleEntity.getCreated() != null) {
                meta.setLastUpdated(scheduleEntity.getCreated());
            }
        }
        schedule.setMeta(meta);

        schedule.setId(scheduleEntity.getId().toString());

        for(ScheduleIdentifier identifier : scheduleEntity.getIdentifiers())
        {
            Identifier ident = schedule.addIdentifier();
            ident = daoutils.getIdentifier(identifier, ident);
        }

        if (scheduleEntity.getActive() != null) {
            schedule.setActive(scheduleEntity.getActive());
        }

        for(ScheduleActor actor : scheduleEntity.getActors()){
            if(actor.getPractitionerRole() != null){
                schedule.addActor().setReference("PractitonerRole/"+actor.getPractitionerRole().getId());
            }

            if(actor.getPractitionerEntity() != null){
                schedule.addActor().setReference("Practitoner/"+actor.getPractitionerEntity().getId());
            }

            if(actor.getHealthcareServiceEntity() != null){
                schedule.addActor().setReference("HealthcareService/"+actor.getHealthcareServiceEntity().getId());
            }

            if(actor.getLocationEntity() != null){
                schedule.addActor().setReference("Location/"+actor.getLocationEntity().getId());
            }

        }

        if (scheduleEntity.getComment() != null) {
            schedule.setComment(scheduleEntity.getComment());
        }


        if (scheduleEntity.getCategory() != null) {
            schedule.getServiceCategory()
                    .addCoding()
                    .setDisplay(scheduleEntity.getCategory().getDisplay())
                    .setSystem(scheduleEntity.getCategory().getSystem())
                    .setCode(scheduleEntity.getCategory().getCode());
        }

        return schedule;

}
 
Example #18
Source File: GoalEntityToFHIRGoalTransformer.java    From careconnect-reference-implementation with Apache License 2.0 2 votes vote down vote up
@Override
public Goal transform(final GoalEntity goalEntity) {
    final Goal goal = new Goal();

    Meta meta = new Meta();

    if (goalEntity.getUpdated() != null) {
        meta.setLastUpdated(goalEntity.getUpdated());
    }
    else {
        if (goalEntity.getCreated() != null) {
            meta.setLastUpdated(goalEntity.getCreated());
        }
    }
    goal.setMeta(meta);

    goal.setId(goalEntity.getId().toString());

    
    if (goalEntity.getPatient() != null) {
        goal
                .setSubject(new Reference("Patient/"+goalEntity.getPatient().getId())
                .setDisplay(goalEntity.getPatient().getNames().get(0).getDisplayName()));
    }

    if (goalEntity.getStatus() != null) {
        goal.setStatus(goalEntity.getStatus());
    }




    for (GoalIdentifier identifier : goalEntity.getIdentifiers()) {
        Identifier ident = goal.addIdentifier();
        ident = daoutils.getIdentifier(identifier, ident);
    }




    return goal;

}