Is there any way we convert hl7 message string to json ? #80
Faisal-hussain-ds
started this conversation in
General
Replies: 1 comment
-
You can create a Message object from the string, followed by extracting the info you'd need from each segment. For example, public function toJson(string $hl7): string
{
return json_encode($this->toArray($hl7));
}
public function toArray(): array
{
$msg = new Message($hl7String, null, true, true, true, true);
$pv1 = $msg->getFirstSegmentInstance('PV1');
$data['physician'] = $pv1->getOrderingProvider(); // This may need to be further parsed for lastname, firstname, NPI etc. Recommended to be in its own function as the logic may get complex
// Likewise, $data['patient'] = $pid->getPatientName(), etc.
return $data;
} You may need to create separate classes for ORM, ORU, OML depending upon the type of messages you're dealing with. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to pass hl7 string and want json response.
can anybody help me , i want to fetch data from other healthcare application.
Beta Was this translation helpful? Give feedback.
All reactions