Save Patient Encounter - Internal

Transaction Specification

Description: This transaction deals with saving a patient's encounter in their medical record. The save message should be able to contain information for all the RHEA supported forms as well as information received from the RapidSMS application. This information should all be stored as observations in the SHR.

 
Input: The HL7 message that contains the patient encounter to be created.

HL7 v2.5 ORU_R01 message.
See corresponding External API call above for specifications.

Output: A positive or negative response.

Sample Messaging Implemenation

Scenario 1

The User posts a valid ORUR01 object to the SHR Adapter module

Sample Request Message

A sample POST request will be as follows,

/openmrs/ws/rest/RHEA/patient/encounters?patientId=1234&idType=ECID

Assuming the path for the SHR webapp is openmrs. For the save encounter request to be successful, the patient specified in the URL must also exist in the database.

This message must also contain an hl7 message in xml format.
A sample message is as follows:

<?xml version="1.0"?>
<ORU_R01 xmlns="urn:hl7-org:v2xml"><?xml version="1.0"?><ORU_R01 xmlns="urn:hl7-org:v2xml">
    <MSH>
        <MSH.1>|</MSH.1>
        <MSH.2>^~\&amp;</MSH.2>
        <MSH.4>
            <HD.1>Shared Health Record</HD.1>
        </MSH.4>
        <MSH.6>
            <HD.1>Point of Care</HD.1>
        </MSH.6>
        <MSH.7>
            <TS.1>20120630103233</TS.1>
        </MSH.7>
        <MSH.9>
            <MSG.1>ORU</MSG.1>
            <MSG.2>R01</MSG.2>
            <MSG.3>ORU_R01</MSG.3>
        </MSH.9>
        <MSH.10>f72dac3d-6e71-42a1-821a-0cbd4a4c5a87</MSH.10>
        <MSH.11>
            <PT.1>D</PT.1>
            <PT.2>C</PT.2>
        </MSH.11>
        <MSH.12>
            <VID.1>2.5</VID.1>
            <VID.2>
                <CE.1>RWA</CE.1>
            </VID.2>
        </MSH.12>
        <MSH.21>
            <EI.1>CLSM_V0.83</EI.1>
        </MSH.21>
    </MSH>
    <ORU_R01.PATIENT_RESULT>
        <ORU_R01.PATIENT>
            <PID>
                <PID.3>
                    <CX.1>1234</CX.1>
                    <CX.5>ECID</CX.5>
                </PID.3>
                <PID.5>
                    <XPN.1>
                        <FN.1>Patient</FN.1>
                    </XPN.1>
                    <XPN.2>John</XPN.2>
                </PID.5>
            </PID>
            <ORU_R01.VISIT>
                <PV1>
                    <PV1.2>0</PV1.2>
                    <PV1.3>
                        <PL.1>1</PL.1>
                        <PL.4>
                            <HD.1>Unknown Location</HD.1>
                        </PL.4>
                    </PV1.3>
                    <PV1.4>ADULTINITIAL</PV1.4>
                    <PV1.7>
                        <XCN.1>2</XCN.1>
                        <XCN.2>
                            <FN.1>Hornblower</FN.1>
                        </XCN.2>
                        <XCN.3>Horatio</XCN.3>
                    </PV1.7>
                    <PV1.44>
                        <TS.1>201206260829</TS.1>
                    </PV1.44>
                </PV1>
            </ORU_R01.VISIT>
        </ORU_R01.PATIENT>
        <ORU_R01.ORDER_OBSERVATION>
            <ORC>
                <ORC.1>RE</ORC.1>
                <ORC.9>
                    <TS.1>201206301032</TS.1>
                </ORC.9>
                <ORC.12>
                    <XCN.1>2</XCN.1>
                </ORC.12>
                <ORC.16>
                    <CE.1>XXX</CE.1>
                    <CE.2>YYY</CE.2>
                    <CE.3>ZZZ</CE.3>
                </ORC.16>
            </ORC>
            <OBR>
                <OBR.1>0</OBR.1>
                <OBR.3>
                    <EI.1>104</EI.1>
                </OBR.3>
                <OBR.4>
                    <CE.2>ADULTINITIAL</CE.2>
                </OBR.4>
                <OBR.7>
                    <TS.1>202506230000</TS.1>
                </OBR.7>
                <OBR.16>
                    <XCN.1>2</XCN.1>
                    <XCN.2>
                        <FN.1>Hornblower</FN.1>
                    </XCN.2>
                    <XCN.3>Horatio</XCN.3>
                </OBR.16>
                <OBR.20>1</OBR.20>
                <OBR.21>Unknown Location</OBR.21>
            </OBR>
        </ORU_R01.ORDER_OBSERVATION>
        <ORU_R01.ORDER_OBSERVATION>
            <OBR>
                <OBR.1>1</OBR.1>
                <OBR.3>
                    <EI.1>104</EI.1>
                </OBR.3>
                <OBR.4>
                    <CE.1>1234</CE.1>
                    <CE.2>NEUTROPHILS</CE.2>
                    <CE.3>LOCAL</CE.3>
                </OBR.4>
                <OBR.18>0</OBR.18>
                <OBR.29>
                    <EIP.2>
                        <EI.3>104</EI.3>
                    </EIP.2>
                </OBR.29>
            </OBR>
            <ORU_R01.OBSERVATION>
                <OBX>
                    <OBX.1>0</OBX.1>
                    <OBX.2>CE</OBX.2>
                    <OBX.3>
                        <CE.1>32</CE.1>
                        <CE.2>MALARIAL SMEAR</CE.2>
                        <CE.3>RW_CS</CE.3>
                    </OBX.3>
                    <OBX.5>
                        <CE.1>664</CE.1>
                        <CE.2>NEGATIVE</CE.2>
                        <CE.3>RW_CS</CE.3>
                    </OBX.5>
                    <OBX.14>
                        <TS.1>20120626202953</TS.1>
                    </OBX.14>
                </OBX>
            </ORU_R01.OBSERVATION>
            <ORU_R01.OBSERVATION>
                <OBX>
                    <OBX.1>1</OBX.1>
                    <OBX.2>NM</OBX.2>
                    <OBX.3>
                        <CE.1>1234</CE.1>
                        <CE.2>NEUTROPHILS</CE.2>
                        <CE.3>LOCAL</CE.3>
                    </OBX.3>
                    <OBX.5>45.0</OBX.5>
                    <OBX.6>
                        <CE.1>%</CE.1>
                        <CE.3>ucum</CE.3>
                    </OBX.6>
                    <OBX.14>
                        <TS.1>20120626202953</TS.1>
                    </OBX.14>
                </OBX>
            </ORU_R01.OBSERVATION>
            <ORU_R01.OBSERVATION>
                <OBX>
                    <OBX.1>2</OBX.1>
                    <OBX.2>CE</OBX.2>
                    <OBX.3>
                        <CE.1>32</CE.1>
                        <CE.2>MALARIAL SMEAR</CE.2>
                        <CE.3>RW_CS</CE.3>
                    </OBX.3>
                    <OBX.5>
                        <CE.1>664</CE.1>
                        <CE.2>NEGATIVE</CE.2>
                        <CE.3>RW_CS</CE.3>
                    </OBX.5>
                    <OBX.14>
                        <TS.1>20120626202953</TS.1>
                    </OBX.14>
                </OBX>
            </ORU_R01.OBSERVATION>
            <ORU_R01.OBSERVATION>
                <OBX>
                    <OBX.1>3</OBX.1>
                    <OBX.2>NM</OBX.2>
                    <OBX.3>
                        <CE.1>1235</CE.1>
                        <CE.2>NUMBER OF WIVES</CE.2>
                        <CE.3>LOCAL</CE.3>
                    </OBX.3>
                    <OBX.5>1.0</OBX.5>
                    <OBX.6>
                        <CE.1># wives</CE.1>
                        <CE.3>ucum</CE.3>
                    </OBX.6>
                    <OBX.14>
                        <TS.1>20120626202953</TS.1>
                    </OBX.14>
                </OBX>
            </ORU_R01.OBSERVATION>
        </ORU_R01.ORDER_OBSERVATION>
        <ORU_R01.ORDER_OBSERVATION>
            <OBR>
                <OBR.1>2</OBR.1>
                <OBR.3>
                    <EI.1>104</EI.1>
                </OBR.3>
                <OBR.18>1</OBR.18>
                <OBR.29>
                    <EIP.2>
                        <EI.3>104</EI.3>
                    </EIP.2>
                </OBR.29>
            </OBR>
            <ORU_R01.OBSERVATION>
                <OBX>
                    <OBX.1>4</OBX.1>
                    <OBX.2>NM</OBX.2>
                    <OBX.3>
                        <CE.1>11638-4</CE.1>
                        <CE.2>TOTAL NUMBER OF CHILDREN SIRED</CE.2>
                        <CE.3>LOCAL</CE.3>
                    </OBX.3>
                    <OBX.5>5.0</OBX.5>
                    <OBX.6>
                        <CE.1># children</CE.1>
                        <CE.3>ucum</CE.3>
                    </OBX.6>
                    <OBX.14>
                        <TS.1>20120628220517</TS.1>
                    </OBX.14>
                </OBX>
            </ORU_R01.OBSERVATION>
            <ORU_R01.OBSERVATION>
                <OBX>
                    <OBX.1>5</OBX.1>
                    <OBX.2>NM</OBX.2>
                    <OBX.3>
                        <CE.1>987</CE.1>
                        <CE.2>BODY MASS INDEX</CE.2>
                        <CE.3>LOCAL</CE.3>
                    </OBX.3>
                    <OBX.5>100.0</OBX.5>
                    <OBX.6>
                        <CE.1>kg/m2</CE.1>
                        <CE.3>ucum</CE.3>
                    </OBX.6>
                    <OBX.14>
                        <TS.1>20120628220637</TS.1>
                    </OBX.14>
                </OBX>
            </ORU_R01.OBSERVATION>
        </ORU_R01.ORDER_OBSERVATION>
    </ORU_R01.PATIENT_RESULT>
</ORU_R01>

Sample Response Messages

HTTP/1.1 201 Created
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: JSESSIONID=1l8yojhdxyuwf;Path=/openmrs
Location: http://localhost:8080/openmrs/ws/rest/RHEA/patient/encounters?enterpriseId=1234&idType=ECID&encounterId=119
ETag: "0d41d8cd98f00b204e9800998ecf8427e"
Content-Length: 0
Server: Jetty(6.1.10)

Note : The location header of the URL contains the encounter id of the newly created encounter