use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project eCRNow by drajer-health.
the class CdaProblemGenerator method generateProblemSection.
public static String generateProblemSection(R4FhirData data, LaunchDetails details) {
StringBuilder sb = new StringBuilder(2000);
List<Condition> conds = data.getConditions();
if (conds != null && !conds.isEmpty()) {
// Generate the component and section end tags
sb.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.COMP_EL_NAME));
sb.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.SECTION_EL_NAME));
sb.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.PROB_SEC_TEMPLATE_ID));
sb.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.PROB_SEC_TEMPLATE_ID, CdaGeneratorConstants.PROB_SEC_TEMPLATE_ID_EXT));
sb.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.CODE_EL_NAME, CdaGeneratorConstants.PROB_SEC_CODE, CdaGeneratorConstants.LOINC_CODESYSTEM_OID, CdaGeneratorConstants.LOINC_CODESYSTEM_NAME, CdaGeneratorConstants.PROB_SEC_NAME));
// Add Title
sb.append(CdaGeneratorUtils.getXmlForText(CdaGeneratorConstants.TITLE_EL_NAME, CdaGeneratorConstants.PROB_SEC_TITLE));
// Add Narrative Text
sb.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.TEXT_EL_NAME));
// Create Table Header.
List<String> list = new ArrayList<>();
list.add(CdaGeneratorConstants.PROB_TABLE_COL_1_TITLE);
list.add(CdaGeneratorConstants.PROB_TABLE_COL_2_TITLE);
sb.append(CdaGeneratorUtils.getXmlForTableHeader(list, CdaGeneratorConstants.TABLE_BORDER, CdaGeneratorConstants.TABLE_WIDTH));
// Add Table Body
sb.append(CdaGeneratorUtils.getXmlForStartElement(CdaGeneratorConstants.TABLE_BODY_EL_NAME));
// Add Body Rows
int rowNum = 1;
for (Condition prob : conds) {
String probDisplayName = CdaGeneratorConstants.UNKNOWN_VALUE;
if (prob.getCode() != null && prob.getCode().getCodingFirstRep() != null && !StringUtils.isEmpty(prob.getCode().getCodingFirstRep().getDisplay())) {
probDisplayName = prob.getCode().getCodingFirstRep().getDisplay();
}
Map<String, String> bodyvals = new LinkedHashMap<>();
bodyvals.put(CdaGeneratorConstants.PROB_TABLE_COL_1_BODY_CONTENT, probDisplayName);
if (prob.getClinicalStatus() != null && prob.getClinicalStatus().getCodingFirstRep() != null && !StringUtils.isEmpty(prob.getClinicalStatus().getCodingFirstRep().getCode()) && (prob.getClinicalStatus().getCodingFirstRep().getCode().contentEquals(ConditionClinical.ACTIVE.toCode()) || prob.getClinicalStatus().getCodingFirstRep().getCode().contentEquals(ConditionClinical.RELAPSE.toCode()))) {
bodyvals.put(CdaGeneratorConstants.PROB_TABLE_COL_2_BODY_CONTENT, CdaGeneratorConstants.TABLE_ACTIVE_STATUS);
} else {
bodyvals.put(CdaGeneratorConstants.PROB_TABLE_COL_2_BODY_CONTENT, CdaGeneratorConstants.TABLE_RESOLVED_STATUS);
}
sb.append(CdaGeneratorUtils.addTableRow(bodyvals, rowNum));
// TODO: ++rowNum or rowNum++
++rowNum;
}
sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.TABLE_BODY_EL_NAME));
// End Table.
sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.TABLE_EL_NAME));
sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.TEXT_EL_NAME));
for (Condition pr : conds) {
// Add the Entries.
sb.append(CdaGeneratorUtils.getXmlForActEntry(CdaGeneratorConstants.TYPE_CODE_DEF));
// Add the problem Concern Act
sb.append(CdaGeneratorUtils.getXmlForAct(CdaGeneratorConstants.ACT_EL_NAME, CdaGeneratorConstants.ACT_CLASS_CODE, CdaGeneratorConstants.MOOD_CODE_DEF));
sb.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.PROB_CONCERN_TEMPLATE_ID));
sb.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.PROB_CONCERN_TEMPLATE_ID, CdaGeneratorConstants.PROB_CONCERN_TEMPLATE_ID_EXT));
sb.append(CdaGeneratorUtils.getXmlForIIUsingGuid());
sb.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.CODE_EL_NAME, CdaGeneratorConstants.PROB_CONC_ACT_CODE, CdaGeneratorConstants.HL7_ACT_CLASS_OID, CdaGeneratorConstants.HL7_ACT_CLASS_NAME, CdaGeneratorConstants.PROB_CONC_ACT_NAME));
if (pr.getClinicalStatus() != null && pr.getClinicalStatus().getCodingFirstRep() != null && !StringUtils.isEmpty(pr.getClinicalStatus().getCodingFirstRep().getCode()) && (pr.getClinicalStatus().getCodingFirstRep().getCode().contentEquals(ConditionClinical.ACTIVE.toCode()) || pr.getClinicalStatus().getCodingFirstRep().getCode().contentEquals(ConditionClinical.RELAPSE.toCode()))) {
sb.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.STATUS_CODE_EL_NAME, CdaGeneratorConstants.ACTIVE_STATUS));
} else {
sb.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.STATUS_CODE_EL_NAME, CdaGeneratorConstants.COMPLETED_STATUS));
}
Pair<Date, TimeZone> onset = CdaFhirUtilities.getActualDate(pr.getOnset());
Pair<Date, TimeZone> abatement = CdaFhirUtilities.getActualDate(pr.getAbatement());
Pair<Date, TimeZone> recordedDate = null;
if (pr.getRecordedDateElement() != null) {
recordedDate = new Pair<>(pr.getRecordedDate(), pr.getRecordedDateElement().getTimeZone());
}
sb.append(CdaGeneratorUtils.getXmlForIVLWithTS(CdaGeneratorConstants.EFF_TIME_EL_NAME, recordedDate, abatement, true));
// Add the Problem Observation
sb.append(CdaGeneratorUtils.getXmlForEntryRelationship(CdaGeneratorConstants.ENTRY_REL_SUBJ_CODE));
sb.append(CdaGeneratorUtils.getXmlForAct(CdaGeneratorConstants.OBS_ACT_EL_NAME, CdaGeneratorConstants.OBS_CLASS_CODE, CdaGeneratorConstants.MOOD_CODE_DEF));
sb.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.PROB_OBS_TEMPLATE_ID));
sb.append(CdaGeneratorUtils.getXmlForTemplateId(CdaGeneratorConstants.PROB_OBS_TEMPLATE_ID, CdaGeneratorConstants.PROB_OBS_TEMPALTE_ID_EXT));
sb.append(CdaGeneratorUtils.getXmlForII(details.getAssigningAuthorityId(), pr.getId()));
sb.append(CdaGeneratorUtils.getXmlForCDWithoutEndTag(CdaGeneratorConstants.CODE_EL_NAME, CdaGeneratorConstants.DIAGNOSIS_SNOMED, CdaGeneratorConstants.SNOMED_CODESYSTEM_OID, CdaGeneratorConstants.SNOMED_CODESYSTEM_NAME, CdaGeneratorConstants.DIAGNOSIS_DISPLAY_NAME));
sb.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.TRANSLATION_EL_NAME, CdaGeneratorConstants.DIAGNOSIS_LOINC, CdaGeneratorConstants.LOINC_CODESYSTEM_OID, CdaGeneratorConstants.LOINC_CODESYSTEM_NAME, CdaGeneratorConstants.DIAGNOSIS_DISPLAY_NAME));
sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.CODE_EL_NAME));
sb.append(CdaGeneratorUtils.getXmlForCD(CdaGeneratorConstants.STATUS_CODE_EL_NAME, CdaGeneratorConstants.COMPLETED_STATUS));
sb.append(CdaGeneratorUtils.getXmlForIVLWithTS(CdaGeneratorConstants.EFF_TIME_EL_NAME, onset, abatement, true));
List<CodeableConcept> cds = new ArrayList<>();
cds.add(pr.getCode());
String codeXml = CdaFhirUtilities.getCodeableConceptXmlForCodeSystem(cds, CdaGeneratorConstants.VAL_EL_NAME, true, CdaGeneratorConstants.FHIR_SNOMED_URL, false);
if (!codeXml.isEmpty()) {
sb.append(codeXml);
} else {
sb.append(CdaFhirUtilities.getCodeableConceptXml(cds, CdaGeneratorConstants.VAL_EL_NAME, true));
}
// End Tag for Entry Relationship
sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.OBS_ACT_EL_NAME));
sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.ENTRY_REL_EL_NAME));
logger.debug("Add Trigger Codes to Problem Observation if applicable {}", pr.getId());
sb.append(addTriggerCodes(details, pr, onset, abatement));
logger.debug("Completed adding Trigger Codes ");
// End Tags for Entries
sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.ACT_EL_NAME));
sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.ENTRY_EL_NAME));
}
// Complete the section end tags.
sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.SECTION_EL_NAME));
sb.append(CdaGeneratorUtils.getXmlForEndElement(CdaGeneratorConstants.COMP_EL_NAME));
} else {
sb.append(generateEmptyProblemSection());
}
return sb.toString();
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project eCRNow by drajer-health.
the class PlanDefinitionProcessor method readErsdBundleFromFile.
private Bundle readErsdBundleFromFile() {
logger.debug("About to read ERSD File {}", ersdFileLocation);
Bundle bundle = null;
try (InputStream in = new FileInputStream(new File(ersdFileLocation))) {
logger.debug("Reading ERSD File ");
bundle = jsonParser.parseResource(Bundle.class, in);
logger.debug("Completed Reading ERSD File");
} catch (Exception e) {
logger.error("Exception Reading ERSD File", e);
}
return bundle;
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project nia-patient-switching-standard-adaptor by NHSDigital.
the class TemplateMapper method createQuestionnaireResponse.
private QuestionnaireResponse createQuestionnaireResponse(RCMRMT030101UK04CompoundStatement compoundStatement, String practiseCode, Patient patient, Optional<Reference> encounter, Observation parentObservation, RCMRMT030101UK04EhrComposition ehrComposition, RCMRMT030101UK04EhrExtract ehrExtract) {
var questionnaireResponse = new QuestionnaireResponse();
var id = compoundStatement.getId().get(0).getRoot();
questionnaireResponse.addItem(createdLinkedId(compoundStatement)).setAuthoredElement(getAuthored(ehrComposition, ehrExtract)).setSubject(new Reference(patient)).setStatus(COMPLETED).setParent(List.of(new Reference(parentObservation))).setIdentifier(buildIdentifier(id, practiseCode)).setMeta(generateMeta(QUESTIONNAIRE_META_PROFILE)).setId(QUESTIONNAIRE_REFERENCE.formatted(id));
encounter.ifPresent(questionnaireResponse::setContext);
return questionnaireResponse;
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project nia-patient-switching-standard-adaptor by NHSDigital.
the class MedicationRequestOrderMapper method mapToOrderMedicationRequest.
public MedicationRequest mapToOrderMedicationRequest(RCMRMT030101UK04EhrExtract ehrExtract, RCMRMT030101UK04MedicationStatement medicationStatement, RCMRMT030101UK04Prescribe supplyPrescribe, String practiseCode) {
var ehrSupplyPrescribeIdExtract = extractEhrSupplyPrescribeId(supplyPrescribe);
var inFulfillmentOfId = extractInFulfillmentOfId(supplyPrescribe);
if (ehrSupplyPrescribeIdExtract.isPresent()) {
var ehrSupplyPrescribeId = ehrSupplyPrescribeIdExtract.get();
MedicationRequest medicationRequest = createMedicationRequestSkeleton(ehrSupplyPrescribeId);
medicationRequest.addIdentifier(buildIdentifier(ehrSupplyPrescribeId, practiseCode));
medicationRequest.setStatus(COMPLETED);
medicationRequest.setIntent(ORDER);
medicationRequest.addDosageInstruction(buildDosage(medicationStatement.getPertinentInformation()));
medicationRequest.setDispenseRequest(buildDispenseRequestForPrescribe(supplyPrescribe));
buildNotesForPrescribe(supplyPrescribe).forEach(medicationRequest::addNote);
medicationMapper.extractMedicationReference(medicationStatement).ifPresent(medicationRequest::setMedication);
inFulfillmentOfId.ifPresent(inFulfillmentId -> {
var supplyAuthorise = extractSupplyAuthorise(ehrExtract, inFulfillmentId);
buildPrescriptionTypeExtension(supplyAuthorise).ifPresent(medicationRequest::addExtension);
medicationRequest.addBasedOn(buildMedicationRequestReference(inFulfillmentId));
});
return medicationRequest;
}
return null;
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project gpconnect-demonstrator by nhsconnect.
the class MedicationOrderResourceProvider method medicationOrderDetailsToMedicationOrderResourceConverter.
private MedicationRequest medicationOrderDetailsToMedicationOrderResourceConverter(MedicationOrderDetails medicationOrderDetails) {
MedicationRequest medicationOrder = new MedicationRequest();
String resourceId = String.valueOf(medicationOrderDetails.getId());
String versionId = String.valueOf(medicationOrderDetails.getLastUpdated().getTime());
String resourceType = medicationOrder.getResourceType().toString();
IdType id = new IdType(resourceType, resourceId, versionId);
medicationOrder.setId(id);
medicationOrder.getMeta().setVersionId(versionId);
medicationOrder.getMeta().setLastUpdated(medicationOrderDetails.getLastUpdated());
switch(medicationOrderDetails.getOrderStatus().toLowerCase(Locale.UK)) {
case "active":
medicationOrder.setStatus(MedicationRequestStatus.ACTIVE);
break;
case "completed":
medicationOrder.setStatus(MedicationRequestStatus.COMPLETED);
break;
case "draft":
medicationOrder.setStatus(MedicationRequestStatus.DRAFT);
break;
case "entered_in_error":
medicationOrder.setStatus(MedicationRequestStatus.ENTEREDINERROR);
break;
case "on_hold":
medicationOrder.setStatus(MedicationRequestStatus.ONHOLD);
break;
case "stopped":
medicationOrder.setStatus(MedicationRequestStatus.STOPPED);
break;
}
if (medicationOrderDetails.getPatientId() != null) {
medicationOrder.setSubject(new Reference("Patient/" + medicationOrderDetails.getPatientId()));
} else {
medicationOrder.setSubject(new Reference());
}
medicationOrder.setRecorder(new Reference("Practitioner/" + medicationOrderDetails.getAutherId()));
medicationOrder.setMedication(new Reference("Medication/" + medicationOrderDetails.getMedicationId()));
medicationOrder.addDosageInstruction().setText(medicationOrderDetails.getDosageText());
MedicationRequestDispenseRequestComponent dispenseRequest = new MedicationRequestDispenseRequestComponent();
dispenseRequest.addExtension(new Extension(SystemURL.SD_EXTENSION_MEDICATION_QUANTITY_TEXT, new StringDt(medicationOrderDetails.getDispenseQuantityText())));
dispenseRequest.addExtension(new Extension(SystemURL.SD_EXTENSION_PERSCRIPTION_REPEAT_REVIEW_DATE, new DateTimeDt(medicationOrderDetails.getDispenseReviewDate())));
dispenseRequest.setId("Medication/" + medicationOrderDetails.getDispenseMedicationId());
dispenseRequest.setNumberOfRepeatsAllowed(medicationOrderDetails.getDispenseRepeatsAllowed());
medicationOrder.setDispenseRequest(dispenseRequest);
return medicationOrder;
}
Aggregations