Search in sources :

Example 1 with MedicationReasonCode

use of uk.gov.hscic.model.medication.MedicationReasonCode in project gpconnect-demonstrator by nhsconnect.

the class MedicationStatementEntityToDetailTransformer method transform.

@Override
public MedicationStatementDetail transform(MedicationStatementEntity statementEntity) {
    MedicationStatementDetail statementDetail = new MedicationStatementDetail();
    statementDetail.setId(statementEntity.getId());
    statementDetail.setLastIssueDate(statementEntity.getLastIssueDate());
    statementDetail.setMedicationRequestPlanId(statementEntity.getMedicationRequestId());
    statementDetail.setStatusCode(statementEntity.getStatusCode());
    statementDetail.setStatusDisplay(statementEntity.getStatusDisplay());
    statementDetail.setMedicationId(statementEntity.getMedicationId());
    statementDetail.setStartDate(statementEntity.getStartDate());
    statementDetail.setEndDate(statementEntity.getEndDate());
    statementDetail.setDateAsserted(statementEntity.getDateAsserted());
    statementDetail.setPatientId(statementEntity.getPatientId());
    statementDetail.setTakenCode(statementEntity.getTakenCode());
    statementDetail.setTakenDisplay(statementEntity.getTakenDisplay());
    statementEntity.getReasonCodes().forEach(rc -> {
        MedicationReasonCode reasonCode = new MedicationReasonCode();
        reasonCode.setId(rc.getId());
        reasonCode.setCode(rc.getCode());
        reasonCode.setDisplay(rc.getDisplay());
        statementDetail.addReasonCode(reasonCode);
    });
    statementEntity.getReasonReferences().forEach(rr -> {
        MedicationReasonReference reasonReference = new MedicationReasonReference();
        reasonReference.setId(rr.getId());
        reasonReference.setReferenceUrl(rr.getReferenceUrl());
        reasonReference.setReferenceId(reasonReference.getReferenceId());
        statementDetail.addReasonReferences(reasonReference);
    });
    statementEntity.getNotes().forEach(n -> {
        MedicationNote note = new MedicationNote();
        note.setId(n.getId());
        note.setAuthorReferenceUrl(n.getAuthorReferenceUrl());
        note.setAuthorId(n.getAuthorId());
        note.setNote(n.getNoteText());
        statementDetail.addNote(note);
    });
    statementDetail.setDosageText(statementEntity.getDosageText());
    statementDetail.setDosagePatientInstruction(statementEntity.getDosageInstruction());
    statementDetail.setDosageLastChanged(statementEntity.getDosageLastChanged());
    statementDetail.setPrescribingAgency(statementEntity.getPrescribingAgency());
    statementDetail.setGuid(statementEntity.getGuid());
    if (statementEntity.getWarningCode() != null) {
        statementDetail.setWarningCode(statementEntity.getWarningCode());
    }
    return statementDetail;
}
Also used : MedicationNote(uk.gov.hscic.model.medication.MedicationNote) MedicationStatementDetail(uk.gov.hscic.model.medication.MedicationStatementDetail) MedicationReasonReference(uk.gov.hscic.model.medication.MedicationReasonReference) MedicationReasonCode(uk.gov.hscic.model.medication.MedicationReasonCode)

Aggregations

MedicationNote (uk.gov.hscic.model.medication.MedicationNote)1 MedicationReasonCode (uk.gov.hscic.model.medication.MedicationReasonCode)1 MedicationReasonReference (uk.gov.hscic.model.medication.MedicationReasonReference)1 MedicationStatementDetail (uk.gov.hscic.model.medication.MedicationStatementDetail)1