Java Code Examples for org.hl7.fhir.dstu3.model.ListResource#setMode()

The following examples show how to use org.hl7.fhir.dstu3.model.ListResource#setMode() . 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: ArgonautConverter.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void processAllergiesSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
	scanSection("Allergies", section);
	ListResource list = new ListResource();
	list.setId(context.baseId+"-list-allergies");
	list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafallergylist");
	list.setSubject(context.subjectRef);
	list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
	list.setTitle(cda.getChild(section, "title").getTextContent());
	list.setStatus(ListStatus.CURRENT);
	list.setDateElement(context.now);
	list.setSource(context.authorRef);
	list.setMode(ListMode.SNAPSHOT);
	buildNarrative(list, cda.getChild(section, "text"));

	int i = 0;
	for (Element c : cda.getChildren(section, "entry")) {
		Element apa = cda.getChild(c, "act"); // allergy problem act
		AllergyIntolerance ai = new AllergyIntolerance();
		ai.setId(context.baseId+"-allergy-"+Integer.toString(i));
		ai.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/allergyintolerance-daf-dafallergyintolerance");
		i++;
		ai.setPatient(context.subjectRef);

		ai.setAssertedDateElement(convert.makeDateTimeFromTS(cda.getChild(cda.getChild(apa, "effectiveTime"), "low")));
		boolean found = false;
		for (Element e : cda.getChildren(apa, "id")) {
			Identifier id = convert.makeIdentifierFromII(e);
			ai.getIdentifier().add(id);
		}
		if (!found) {
			list.addEntry().setItem(new Reference().setReference("AllergyIntolerance/"+ai.getId()));

			Element ao = cda.getChild(cda.getChild(apa, "entryRelationship"), "observation"); // allergy observation
			if (!cda.getChild(ao, "value").getAttribute("code").equals("419511003"))
				throw new Error("unexpected code");
			// nothing....

			// no allergy status observation
			List<Element> reactions = cda.getChildren(ao, "entryRelationship");
			Element pe = cda.getChild(cda.getChild(cda.getChild(ao, "participant"), "participantRole"), "playingEntity");
			Element pec = cda.getChild(pe, "code");
			if (pec == null || !Utilities.noString(pec.getAttribute("nullFlavor"))) {
				String n = cda.getChild(pe, "name").getTextContent();
				//				if (n.contains("No Known Drug Allergies") && reactions.isEmpty())
				//					ai.setSubstance(new CodeableConcept().setText(n)); // todo: what do with this?
				//				else
				ai.setCode(new CodeableConcept().setText(n));
			} else
				ai.setCode(inspectCode(convert.makeCodeableConceptFromCD(pec), null));
			recordAllergyCode(ai.getCode());
			if (!reactions.isEmpty()) {
				AllergyIntoleranceReactionComponent aie = ai.addReaction();
				for (Element er : reactions) {
					Element ro = cda.getChild(er, "observation");
					aie.addManifestation(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(ro, "value")), null));
				}
			}

			saveResource(ai);
		}
	}
	saveResource(list);
}
 
Example 2
Source File: ArgonautConverter.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void processVitalSignsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
	scanSection("Vital Signs", section);
	ListResource list = new ListResource();
	list.setId(context.baseId+"-list-vitalsigns");
	//. list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafproblemlist"); no list
	list.setSubject(context.subjectRef);
	list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
	list.setTitle(cda.getChild(section, "title").getTextContent());
	list.setStatus(ListStatus.CURRENT);
	list.setMode(ListMode.SNAPSHOT);
	list.setDateElement(context.now);
	list.setSource(context.authorRef);
	buildNarrative(list, cda.getChild(section, "text"));

	int i = 0;
	for (Element c : cda.getChildren(section, "entry")) {
		Element org = cda.getChild(c, "organizer"); // problem concern act
		for (Element oc : cda.getChildren(org, "component")) {
			Element o = cda.getChild(oc, "observation"); // problem concern act
			Observation obs = new Observation();
			obs.setId(context.baseId+"-vitals-"+Integer.toString(i));
			obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-vitalsigns-dafvitalsigns");
			i++;
			obs.setSubject(context.subjectRef);
			obs.setContext(new Reference().setReference("Encounter/"+context.encounter.getId()));
			obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), null));

			boolean found = false;
			for (Element e : cda.getChildren(o, "id")) {
				Identifier id = convert.makeIdentifierFromII(e);
				obs.getIdentifier().add(id);
			}

			if (!found) {
				list.addEntry().setItem(new Reference().setReference("Observation/"+obs.getId()));
				obs.setStatus(ObservationStatus.FINAL);
				obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(o, "effectiveTime")));
				String v = cda.getChild(o, "value").getAttribute("value");
				if (!Utilities.isDecimal(v, true)) {
					obs.setDataAbsentReason(inspectCode(new CodeableConcept().setText(v), null));
				} else
					obs.setValue(convert.makeQuantityFromPQ(cda.getChild(o, "value")));
				saveResource(obs, "-vs");
			}
		}
	}
	saveResource(list, "-vs");
}