Search in sources :

Example 1 with MedicationAdministrationDetail

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

the class MedicationAdministrationResourceProvider method getMedicationAdministrationsForPatientId.

@Search
public List<MedicationAdministration> getMedicationAdministrationsForPatientId(@RequiredParam(name = "patient") String patientId) {
    ArrayList<MedicationAdministration> medicationAdministrations = new ArrayList<>();
    List<MedicationAdministrationDetail> medicationAdministrationDetailList = medicationAdministrationSearch.findMedicationAdministrationForPatient(Long.parseLong(patientId));
    if (medicationAdministrationDetailList != null && !medicationAdministrationDetailList.isEmpty()) {
        for (MedicationAdministrationDetail medicationAdministrationDetail : medicationAdministrationDetailList) {
            MedicationAdministration medicationAdministration = new MedicationAdministration();
            String resourceId = String.valueOf(medicationAdministrationDetail.getId());
            String versionId = String.valueOf(medicationAdministrationDetail.getLastUpdated().getTime());
            String resourceType = medicationAdministration.getResourceType().toString();
            IdType id = new IdType(resourceType, resourceId, versionId);
            medicationAdministration.setId(id);
            medicationAdministration.getMeta().setVersionId(versionId);
            medicationAdministration.getMeta().setLastUpdated(medicationAdministrationDetail.getLastUpdated());
            medicationAdministration.addDefinition(new Reference("Patient/" + medicationAdministrationDetail.getPatientId()));
            medicationAdministration.addDefinition(new Reference("Practitioner/" + medicationAdministrationDetail.getPractitionerId()));
            medicationAdministration.setPrescription(new Reference("MedicationOrder/" + medicationAdministrationDetail.getPrescriptionId()));
            medicationAdministration.setEffective(new DateType(medicationAdministrationDetail.getAdministrationDate()));
            medicationAdministration.setMedication(new Reference("Medication/" + medicationAdministrationDetail.getMedicationId()));
            medicationAdministrations.add(medicationAdministration);
        }
    }
    return medicationAdministrations;
}
Also used : MedicationAdministrationDetail(uk.gov.hscic.model.medication.MedicationAdministrationDetail) Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) MedicationAdministration(org.hl7.fhir.dstu3.model.MedicationAdministration) DateType(org.hl7.fhir.dstu3.model.DateType) IdType(org.hl7.fhir.dstu3.model.IdType) Search(ca.uhn.fhir.rest.annotation.Search) MedicationAdministrationSearch(uk.gov.hscic.medication.administration.MedicationAdministrationSearch)

Example 2 with MedicationAdministrationDetail

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

the class MedicationAdministrationEntityToMedicationAdministrationDetailTransformer method transform.

@Override
public MedicationAdministrationDetail transform(MedicationAdministrationEntity item) {
    MedicationAdministrationDetail administrationDetail = new MedicationAdministrationDetail();
    administrationDetail.setId(item.getId());
    administrationDetail.setPatientId(item.getPatientId());
    administrationDetail.setPractitionerId(item.getPractitionerId());
    administrationDetail.setEncounterId(item.getEncounterId());
    administrationDetail.setPrescriptionId(item.getPrescriptionId());
    administrationDetail.setAdministrationDate(item.getAdministrationDate());
    administrationDetail.setMedicationId(item.getMedicationId());
    administrationDetail.setLastUpdated(item.getLastUpdated());
    return administrationDetail;
}
Also used : MedicationAdministrationDetail(uk.gov.hscic.model.medication.MedicationAdministrationDetail)

Aggregations

MedicationAdministrationDetail (uk.gov.hscic.model.medication.MedicationAdministrationDetail)2 Search (ca.uhn.fhir.rest.annotation.Search)1 ArrayList (java.util.ArrayList)1 DateType (org.hl7.fhir.dstu3.model.DateType)1 IdType (org.hl7.fhir.dstu3.model.IdType)1 MedicationAdministration (org.hl7.fhir.dstu3.model.MedicationAdministration)1 Reference (org.hl7.fhir.dstu3.model.Reference)1 MedicationAdministrationSearch (uk.gov.hscic.medication.administration.MedicationAdministrationSearch)1