Exemplo n.º 1
0
        public string PostMedicationOrder(string patientID, string medicationName)
        {
            //Potential Parameters to pass in:
            //patientID, medicationName, system, and display

            //First we need to create our medication
            Medication medication = new Medication();

            medication.Code = new CodeableConcept("ICD-10", medicationName);

            //Now we need to push this to the server and grab the ID
            var    medicationResource   = fhirClient.Create <Hl7.Fhir.Model.Medication>(medication);
            string medicationResourceID = medicationResource.Id;

            //Create an empty medication order resource and then assign attributes
            Hl7.Fhir.Model.MedicationOrder fhirMedicationOrder = new Hl7.Fhir.Model.MedicationOrder();

            //There is no API for "Reference" in MedicationOrder model, unlike Patient model.
            //You must initialize ResourceReference inline.
            fhirMedicationOrder.Medication = new ResourceReference()
            {
                Reference = fhirClient.Endpoint.OriginalString + "Medication/" + medicationResourceID,
                Display   = "EhrgoHealth"
            };

            //Now associate Medication Order to a Patient
            fhirMedicationOrder.Patient           = new ResourceReference();
            fhirMedicationOrder.Patient.Reference = "Patient/" + patientID;

            //Push the local patient resource to the FHIR Server and expect a newly assigned ID
            var medicationOrderResource = fhirClient.Create <Hl7.Fhir.Model.MedicationOrder>(fhirMedicationOrder);

            //   medicationOrderResource.Medication
            String returnID = "The newly created Medication ID is: ";

            returnID += medicationOrderResource.Id;
            return(returnID);
        }
Exemplo n.º 2
0
        public static void AddMedicationOrder(string id, string medicationName)
        {
            using (var dbcontext = new ApplicationDbContext())
            {
                var user = dbcontext.Users.FirstOrDefault(a => a.Id == id);
                //todo: I'm not sure about the web portion with regards with what the view should return, I leave
                //      leave that to you, but I left logic to return the medication order ID if you desire. To
                //      show whether the post was successful

                //todo: I do not know where the medicationName will be pulled from, so change harcoded "medicationName"
                //      to the parameter name you expect to use.

                //Full list of Parameters you may also decide to pass in:
                //patientID (done), medicationName, system, and display

                //First let us create the FHIR client
                var fhirClient = new FhirClient(Constants.HapiFhirServerBase);

                //First we need to create our medication
                var medication = new Medication
                {
                    Code = new CodeableConcept("ICD-10", medicationName)
                };

                //Now we need to push this to the server and grab the ID
                var medicationResource = fhirClient.Create<Hl7.Fhir.Model.Medication>(medication);
                var medicationResourceID = medicationResource.Id;

                //Create an empty medication order resource and then assign attributes
                var fhirMedicationOrder = new Hl7.Fhir.Model.MedicationOrder();

                //There is no API for "Reference" in MedicationOrder model, unlike Patient model.
                //You must initialize ResourceReference inline.
                fhirMedicationOrder.Medication = new ResourceReference()
                {
                    Reference = fhirClient.Endpoint.OriginalString + "Medication/" + medicationResourceID,
                    Display = "EhrgoHealth"
                };

                //Now associate Medication Order to a Patient
                fhirMedicationOrder.Patient = new ResourceReference();
                fhirMedicationOrder.Patient.Reference = "Patient/" + user.FhirPatientId;

                //Push the local patient resource to the FHIR Server and expect a newly assigned ID
                var medicationOrderResource = fhirClient.Create<Hl7.Fhir.Model.MedicationOrder>(fhirMedicationOrder);
            }
        }