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;
}
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;
}
Aggregations