fhirbase / fhirbase-plv8

[DEPRECATED] Fhirbase 2.0 is an FHIR relational storage
https://health-samurai.io/fhirbase
Other
105 stars 39 forks source link

Precision loss on write #108

Open vadi2 opened 8 years ago

vadi2 commented 8 years ago

Using v1.3.0.13, precision for trailing 0's on FHIR decimals is lost, while it is important to keep (http://hl7.org/fhir/2016Jan/datatypes.html#precision, http://hl7.org/fhir/2016Jan/json.html#decimal)

Test case:

select fhir_create_resource('{"allowId": true, "resource":{"resourceType":"Claim","id":"12345410528059763","text":{"status":"generated","div":"<div>A human-readable rendering of the Oral Health Claim</div>"},"type":"oral","identifier":[{"system":"http://happyvalley.com/claim","value":"12345410528059763"}],"created":"2014-08-16","target":{"reference":"Organization/2"},"organization":{"reference":"Organization/1"},"use":"complete","priority":{"code":"normal"},"payee":{"type":{"code":"provider"}},"diagnosis":[{"sequence":1,"diagnosis":{"code":"1234627028825"}}],"patient":{"reference":"Patient/1"},"coverage":[{"sequence":1,"focal":true,"coverage":{"reference":"Coverage/3rf7PHeT"},"relationship":{"code":"self"}}],"item":[{"sequence":1,"type":{"code":"service"},"provider":{"reference":"Practitioner/example"},"service":{"system":"http://hl7.org/fhir/ex-USCLS","code":"1201"},"servicedDate":"2014-08-16","unitPrice":{"value":135.57,"system":"urn:iso:std:iso:4217","code":"USD"},"net":{"value":135.57,"system":"urn:iso:std:iso:4217","code":"USD"}},{"sequence":2,"type":{"code":"service"},"provider":{"reference":"Practitioner/example"},"service":{"system":"http://hl7.org/fhir/ex-USCLS","code":"21211"},"servicedDate":"2014-08-16","unitPrice":{"value":105.0,"system":"urn:iso:std:iso:4217","code":"USD"},"net":{"value":105.0,"system":"urn:iso:std:iso:4217","code":"USD"},"bodySite":{"system":"http://hl7.org/fhir/ex-tooth","code":"21"},"subSite":[{"system":"http://hl7.org/fhir/FDI-surface","code":"L"}]},{"sequence":3,"type":{"code":"group"},"provider":{"reference":"Practitioner/example"},"service":{"system":"http://hl7.org/fhir/ex-USCLS","code":"27211"},"servicedDate":"2014-08-16","unitPrice":{"value":1100.0,"system":"urn:iso:std:iso:4217","code":"USD"},"net":{"value":1100.0,"system":"urn:iso:std:iso:4217","code":"USD"},"bodySite":{"system":"http://hl7.org/fhir/ex-tooth","code":"36"},"detail":[{"sequence":1,"type":{"code":"service"},"service":{"system":"http://hl7.org/fhir/ex-USCLS","code":"27211"},"unitPrice":{"value":750.0,"system":"urn:iso:std:iso:4217","code":"USD"},"net":{"value":750.0,"system":"urn:iso:std:iso:4217","code":"USD"}},{"sequence":2,"type":{"code":"service"},"service":{"system":"http://hl7.org/fhir/ex-USCLS","code":"99333"},"unitPrice":{"value":350.0,"system":"urn:iso:std:iso:4217","code":"USD"},"net":{"value":350.0,"system":"urn:iso:std:iso:4217","code":"USD"}}]}]}}');

Resource stored in Postres according to pgAdmin:

{"id": "12345410528059763", "use": "complete", "item": [{"net": {"code": "USD", "value": 135.57, "system": "urn:iso:std:iso:4217"}, "type": {"code": "service"}, "service": {"code": "1201", "system": "http://hl7.org/fhir/ex-USCLS"}, "provider": {"reference": "Practitioner/example"}, "sequence": 1, "unitPrice": {"code": "USD", "value": 135.57, "system": "urn:iso:std:iso:4217"}, "servicedDate": "2014-08-16"}, {"net": {"code": "USD", "value": 105, "system": "urn:iso:std:iso:4217"}, "type": {"code": "service"}, "service": {"code": "21211", "system": "http://hl7.org/fhir/ex-USCLS"}, "subSite": [{"code": "L", "system": "http://hl7.org/fhir/FDI-surface"}], "bodySite": {"code": "21", "system": "http://hl7.org/fhir/ex-tooth"}, "provider": {"reference": "Practitioner/example"}, "sequence": 2, "unitPrice": {"code": "USD", "value": 105, "system": "urn:iso:std:iso:4217"}, "servicedDate": "2014-08-16"}, {"net": {"code": "USD", "value": 1100, "system": "urn:iso:std:iso:4217"}, "type": {"code": "group"}, "detail": [{"net": {"code": "USD", "value": 750, "system": "urn:iso:std:iso:4217"}, "type": {"code": "service"}, "service": {"code": "27211", "system": "http://hl7.org/fhir/ex-USCLS"}, "sequence": 1, "unitPrice": {"code": "USD", "value": 750, "system": "urn:iso:std:iso:4217"}}, {"net": {"code": "USD", "value": 350, "system": "urn:iso:std:iso:4217"}, "type": {"code": "service"}, "service": {"code": "99333", "system": "http://hl7.org/fhir/ex-USCLS"}, "sequence": 2, "unitPrice": {"code": "USD", "value": 350, "system": "urn:iso:std:iso:4217"}}], "service": {"code": "27211", "system": "http://hl7.org/fhir/ex-USCLS"}, "bodySite": {"code": "36", "system": "http://hl7.org/fhir/ex-tooth"}, "provider": {"reference": "Practitioner/example"}, "sequence": 3, "unitPrice": {"code": "USD", "value": 1100, "system": "urn:iso:std:iso:4217"}, "servicedDate": "2014-08-16"}], "meta": {"extension": [{"url": "fhir-request-method", "valueString": "POST"}, {"url": "fhir-request-uri", "valueUri": "Claim"}], "versionId": "67ba0290-4791-4085-bc34-d5fc3621a2c8", "lastUpdated": "2016-04-27T22:06:57.089Z"}, "text": {"div": "<div>A human-readable rendering of the Oral Health Claim</div>", "status": "generated"}, "type": "oral", "payee": {"type": {"code": "provider"}}, "target": {"reference": "Organization/2"}, "created": "2014-08-16", "patient": {"reference": "Patient/1"}, "coverage": [{"focal": true, "coverage": {"reference": "Coverage/3rf7PHeT"}, "sequence": 1, "relationship": {"code": "self"}}], "priority": {"code": "normal"}, "diagnosis": [{"sequence": 1, "diagnosis": {"code": "1234627028825"}}], "identifier": [{"value": "12345410528059763", "system": "http://happyvalley.com/claim"}], "organization": {"reference": "Organization/1"}, "resourceType": "Claim"}

105.0 gets turned into 105.

vadi2 commented 7 years ago

Any updates on this by chance?

niquola commented 7 years ago

This is quite problematic, because standard json parser of v8 looses this information. There was long thread in FHIR chat, only solution to use string to represent such numbers.

On Tue, Oct 4, 2016, 11:50 AM Vadim Peretokin notifications@github.com wrote:

Any updates on this by chance?

— You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub https://github.com/fhirbase/fhirbase-plv8/issues/108#issuecomment-251330941, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB9Qt3DGXzwGfdBCN07Ci-awEQePbEHks5qwhNOgaJpZM4IRaTO .

vadi2 commented 7 years ago

If FHIR represented them as a string, that'd be the easiest... do you have a link to the chat discussion? What was the outcome?