use of de.difuture.uds.odm2fhir.odm.model.ItemData in project odm2fhir by num-codex.
the class ImagingProcedures method map.
protected Stream<DomainResource> map(FormData formData) {
var techniqueGroup = formData.getItemGroupData("bildgebung.bildgebende_verfahren_ct");
var befundGroup = formData.getItemGroupData("bildgebung.befund_bildgebender_verfahren_ct");
var generalCoding = formData.getItemData("bildgebende_verfahren");
if (!"1".equals(generalCoding.getValue())) {
return Stream.empty();
}
var itemDatas = Stream.of(techniqueGroup.getItemData(), befundGroup.getItemData()).flatMap(List::stream).collect(toMap(ItemData::getItemOID, identity()));
return Stream.of("ct", "roentgen", "us").filter(type -> contains(itemDatas.get("bildgebende_verfahren_" + type).getValue(), "410605003")).filter(type -> !(itemDatas.get("befund_bildgebender_verfahren_" + type).isEmpty())).flatMap(type -> {
var diagnosticReport = createDiagnosticReport(itemDatas.get("befund_bildgebender_verfahren_" + type));
var procedure = createProcedure(itemDatas.get("bildgebende_verfahren_" + type)).addReport(new Reference(format("%s/%s", DIAGNOSTICREPORT.toCode(), diagnosticReport.getId())));
return Stream.of(diagnosticReport, procedure);
});
}
use of de.difuture.uds.odm2fhir.odm.model.ItemData in project odm2fhir by num-codex.
the class SOFAScore method createObservation.
private Observation createObservation(List<ItemData> itemDatas, ItemData sofaTotalScore, ItemData dateCoding) {
var observation = (Observation) new Observation().addIdentifier(createIdentifier(OBSERVATION, sofaTotalScore).setType(OBI).setAssigner(getOrganizationReference())).setStatus(FINAL).setEffective(createDateTimeType(dateCoding)).addCategory(SURVEY).setCode(createCodeableConcept(createCoding(ECRF_PARAMETER_CODES, "06", "SOFA-Score")).setText("Sepsis-related organ failure assessment score")).setMeta(createMeta(NUMStructureDefinition.SOFA_SCORE));
itemDatas.stream().map(ItemData::getValue).filter(StringUtils::isNotBlank).forEach(code -> observation.addComponent(new ObservationComponentComponent().setCode(createCodeableConcept(createCoding(SOFA_SCORE, chop(code), getDisplay(chop(code)))).setText(getDefinition(chop(code)))).setValue(createCodeableConcept(createCoding(SOFA_SCORE, code, getDisplay(code))).setText(getDefinition(code)))));
if (sofaTotalScore.isEmpty()) {
observation.setDataAbsentReason(UNKNOWN);
} else {
observation.setValue(new IntegerType().setValue(Integer.valueOf(sofaTotalScore.getValue())));
}
return observation;
}
use of de.difuture.uds.odm2fhir.odm.model.ItemData in project odm2fhir by num-codex.
the class BroadConsent method createConsent.
@SuppressWarnings("fallthrough")
private Consent createConsent(FormData formData) {
var identifier = createIdentifier(CONSENT, formData.getItemData("miibc_consent_status"));
var consent = (Consent) new Consent().addIdentifier(identifier).setDateTimeElement(createDateTimeType(formData.getItemData("miibc_dat_dok"))).addOrganization(getOrganizationReference()).setScope(RESEARCH).addCategory(createCodeableConcept(createCoding(LOINC, "57016-8", "Privacy policy acknowledgment Document"))).addPolicy(new ConsentPolicyComponent().setUri(POLICY)).setMeta(createMeta(GERMAN_CONSENT));
switch(formData.getItemData("miibc_consent_status").getValue()) {
case // agreed
"1":
consent.setStatus(ConsentState.ACTIVE);
break;
case // rejected
"2":
consent.setStatus(REJECTED);
break;
case // revoked
"3":
var revocationDateItem = formData.getItemData("miibc_w_dat_dok");
switch(formData.getItemData("miibc_widerruf").getValue()) {
case // fully revoked
"1":
consent.setStatus(INACTIVE).setDateTimeElement(// revocation -> replace 'consentDate' by 'revocationDate'
createDateTimeType(revocationDateItem));
break;
case // partly revoked
"2":
// revocation -> replace 'consentDate' by 'revocationDate'
consent.setDateTimeElement(createDateTimeType(revocationDateItem));
// not revoked
case "3":
case // unknown (REVOCATION-Status, not CONSENT-Status!)
"4":
// default if not revoked
consent.setStatus(ConsentState.ACTIVE);
break;
}
break;
case // unknown
"4":
// skip if general CONSENT-Status is 'unknown'
return new Consent();
}
var mainProvisionComponent = new Consent.provisionComponent().setType(DENY);
if (consent.getDateTime() != null) {
mainProvisionComponent.setPeriod(new Period().setStart(consent.getDateTime()).setEnd(addYears(consent.getDateTime(), 30)));
}
if (ConsentState.ACTIVE == consent.getStatus()) {
// add more Consent details only if consented/not fully revoked
mainProvisionComponent.setProvision(ELEMENTS.stream().map(key -> "gee_" + key).map(formData::getItemData).filter(not(ItemData::isEmpty)).map(itemData -> {
var specificAnswerItemName = itemData.getItemOID();
var specificAnswerItemValue = itemData.getValue();
var partProvisionComponent = new Consent.provisionComponent().addCode(createCodeableConcept(createCoding("urn:oid:" + BASE_OID, BASE_OID + "." + OIDS.get(removeStart(specificAnswerItemName, "gee_") + "_" + specificAnswerItemValue), specificAnswerItemName)));
if (!mainProvisionComponent.getPeriod().isEmpty()) {
var period = mainProvisionComponent.getPeriod().copy();
if ("gee_krankenkassendaten_retro".equals(specificAnswerItemName)) {
period.setEnd(period.getStart()).setStart(addYears(period.getStart(), -5));
} else if ("gee_krankenkassendaten_pro".equals(specificAnswerItemName)) {
period.setEnd(addYears(period.getStart(), 5));
}
partProvisionComponent.setPeriod(period);
}
switch(specificAnswerItemValue) {
case // agreed
"1":
partProvisionComponent.setType(PERMIT);
break;
// rejected
case "2":
case // revoked
"4":
partProvisionComponent.setType(DENY);
break;
// unknown
case "3":
}
return partProvisionComponent;
}).collect(toList()));
}
return consent.setProvision(mainProvisionComponent);
}
Aggregations